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.

Était-ce utile?

La 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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top