Question

I'm writing a program A and use syslog() to do logging. Instead of logging to default /var/log/messages or other default system log files, can I specify my own log file and use syslog() to log to it? (I really want to make use of syslogd's facility to manage this log file.) What configurations is needed in /etc/syslog.conf? Thanks.

Was it helpful?

Solution

You'll need to pick a logging facility, presumably one of LOG_LOCAL0 through LOG_LOCAL7 (though it's unlikely anyone will notice LOG_NEWS or LOG_UUCP being overwritten), and then create a line in syslog.conf in the form of:

localn.*     my_logfile
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top