-
Notifications
You must be signed in to change notification settings - Fork 307
Configuring append mode log files via Syslog NG
On systems where Systemd is not recent enough (earlier than v240, e.g. on Ubuntu 18.04), it's not possible to configure the unit to write to the logs in append mode.
In such cases, one can send the log messages to the syslog, and send them to a separate file.
As a preliminary step, after installing the unit, edit it:
systemctl edit --user --full sidekiq
and replace StandardOutput
and StandardError
with the following entries:
StandardOutput=syslog
StandardError=syslog
then reload the unit(s):
systemctl daemon-reload
Sidekiq's log messages will now be sent to the syslog.
Add the following entries to /etc/syslog_ng/syslog-ng.conf
:
filter f_sidekiq {
program("sidekiq");
};
log {
source(s_src);
filter(f_sidekiq);
destination(d_sidekiq);
};
destination d_sidekiq {
file("/path/to/sidekiq.log", owner("the-sidekiq-user"), group("the-sidekiq-user"));
};
and restart Syslog-NG: systemctl restart syslog-ng
. The sidekiq messages will now be stored both in the file specified above, and the syslog file.
If one doesn't want the messages to be stored in the syslog file anymore, append the condition and not filter(f_sidekiq)
to f_error
and f_messages
(again, in /etc/syslog_ng/syslog-ng.conf
), for example:
filter f_error {
level(err .. emerg)
and not filter(f_sidekiq) # added
;};
filter f_messages {
level(info,notice,warn)
and not facility(auth,authpriv,cron,daemon,mail,news)
and not filter(f_sidekiq) # added
;};
and restart Syslog-NG again.