I am trying to write different entries in separate log files from an application. For the reason I'm trying to figure out, all entries are displayed in all log files. What can i do wrong?
I only need critical entries to enter /tmp/log/critical.log and debug entries to enter the /tmp/log/debug.log file, while all enteries can enter the log file / tmp / log / all .log.
Listed below are the entries in /etc/rsyslog.conf
local0.* /tmp/log/all.log local0.alert /tmp/log/alert.log local0.crit /tmp/log/critical.log local0.debug /tmp/log/debug.log local0.emerg /tmp/log/emergency.log local0.err /tmp/log/error.log local0.info /tmp/log/info.log local0.notice /tmp/log/notice.log local0.warning /tmp/log/warning.log
My sample c writing syslog entries ...
#include<syslog.h> main() { openlog("myapp",LOG_CONS|LOG_PID|LOG_NDELAY,LOG_LOCAL0); syslog(LOG_EMERG|LOG_LOCAL0,"Emergency",getuid()); syslog(LOG_ALERT|LOG_LOCAL0,"Alert",getuid()); syslog(LOG_CRIT|LOG_LOCAL0,"Critical",getuid()); syslog(LOG_ERR|LOG_LOCAL0,"Error",getuid()); syslog(LOG_WARNING|LOG_LOCAL0,"Warning",getuid()); syslog(LOG_NOTICE|LOG_LOCAL0,"Notice",getuid()); syslog(LOG_INFO|LOG_LOCAL0,"Information",getuid()); syslog(LOG_DEBUG|LOG_LOCAL0,"Debug",getuid()); closelog(); }
source share