Merge pull request #2 from matrix-org/jcgruenhage/logrotate

rotate logs
This commit is contained in:
Michael Kaye 2018-08-17 15:50:37 +01:00 committed by GitHub
commit 7b62526650
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 5 deletions

View file

@ -18,3 +18,4 @@ matrix_synapse_registration_secret: "{{ matrix_registration_secret }}"
matrix_synapse_macaroon_secret_key: "{{ matrix_macaroon_key }}"
matrix_synapse_signing_key_path: "/opt/synapse/ssl/{{ matrix_synapse_domain }}.signing.key"
matrix_synapse_version: "v0.28.1"
matrix_synapse_log_days_keep: 30

View file

@ -0,0 +1,2 @@
if $programname == 'matrix_synapse' then /var/log/matrix_synapse/matrix_synapse.log
if $programname == 'matrix_synapse' then ~

View file

@ -9,3 +9,8 @@
state: restarted
enabled: yes
- name: restart rsyslog
become: yes
service:
name: rsyslog
state: restarted

View file

@ -36,6 +36,18 @@
owner: synapse
group: synapse
- name: copy syslog config
copy:
src: matrix_synapse.conf
dest: /etc/rsyslog.d/matrix_synapse.conf
owner: root
notify: restart rsyslog
- name: template logrotate config
template:
src: logrotate.j2
dest: /etc/logrotate.d/matrix_synapse
- name: Deploy log config
template:
src: "log.config.j2"

View file

@ -2,7 +2,7 @@ version: 1
formatters:
precise:
format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s- %(message)s'
format: '%(name)s - %(lineno)d - %(levelname)s - %(request)s- %(message)s'
filters:
context:

9
templates/logrotate.j2 Normal file
View file

@ -0,0 +1,9 @@
/var/log/matrix_synapse/matrix_synapse.log {
daily
rotate {{ matrix_synapse_log_days_keep }}
compress
shred
postrotate
/usr/bin/pkill -HUP rsyslogd
endscript
}

View file

@ -9,10 +9,8 @@ ExecStop=/opt/synapse/env/bin/synctl stop /opt/synapse/homeserver.yaml
User=synapse
Group=synapse
Restart=always
StandardOut=syslog
SyslogIdentifier=matrix-synapse
SyslogFacility=local3
StandardOutput=syslog
SyslogIdentifier=matrix_synapse
[Install]
WantedBy=default.target