Why is syslog() call not doing what i want it to?

Why is syslog() call not doing what i want it to?

My program looks like:

#include <syslog.h>
void main(int argc,char *argv[])
{
syslog(LOG_EMERG,"This is an emergency message\n"));
syslog(LOG_ALERT,"This is an alert message\n");
syslog(LOG_CRIT,"This is a critical message\n");
syslog(LOG_ERR,"This is an error message\n");
syslog(LOG_WARNING,"This is a warning\n");
syslog(LOG_NOTICE,"This is a notice\n");
syslog(LOG_INFO,"This is an informal message\n");
syslog(LOG_DEBUG,"This is a debug message\n");
}

It doesn't log all the messages to /var/adm/syslog - why not?

First of all, the LOG_EMERG can not be used with user processes and
should
return -1 (if you check the return status). This is not documented in
the
man page! All the other messages should appear, but your /etc/syslog.conf
file might not be configured correctly. To test it, replace the
/etc/syslog.conf with the following line:

*.debug /var/adm/syslog

Then do: kill -HUP `cat /etc/syslog.pid`
Then run the test program and then tail the /var/adm/syslog file
and you should see all the messages, ie:

Nov 23 09:02:54 orca syslogd: restart
Nov 23 09:02:58 orca syslog: This is an alert message
Nov 23 09:02:58 orca syslog: This is a critical message
Nov 23 09:02:58 orca syslog: This is an error message
Nov 23 09:02:58 orca syslog: This is a warning
Nov 23 09:02:58 orca syslog: This is a notice
Nov 23 09:02:58 orca syslog: This is an informal message
Nov 23 09:02:58 orca syslog: This is a debug message



Home
FAQ