The following is an example of writing to the message log in Linux with C
from here, maybe here and also here if you are feeling brave.
#include <syslog.h>
#include <stdio.h>
int main()
{
setlogmask (LOG_UPTO (LOG_NOTICE));
openlog ("myprogramlog", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
for (int x=0;x<10;x++)
{
syslog (LOG_NOTICE, "Program started, count = %d",x);
syslog (LOG_INFO, "A tree falls in a forest");
}
closelog ();
return 0;
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.