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.

有帮助吗?

解决方案

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top