I have spent lot of time to figure this one out, but no success. I'm fairly new to Linux application management and logging.
Problem:
Not able to log data to /var/log/messages when starting syslog-ng using systemd. But when syslog-ng is started from shell, it logs fine to /var/log/messages. I'm using logger utility to test this.
After doing some research and I think I may have found the problem, but don't know how to fix it.
When systemd starts the process, syslog-ng reads from /run/systemd/journal/syslog socket instead of /dev/log/ and logger utility writes messages to /dev/log. I have changed the below entry in syslog-ng.conf file.
source src {
system();
internal();
};
to
source src {
unix-dgram("/dev/log");
internal();
};
Also, I have set below line in journald.conf and restarted it.
ForwardToSyslog=yes
This is the lsof output for process started with systemd
syslog-ng 23425 root 3u unix 0xffff881fce1f1e00 0t0 9281890 /run/systemd/journal/syslog
and process started on shell manually
syslog-ng 19482 root 6u unix 0xffff881fcdd5c380 0t0 10168394 /dev/log