Start logging with syslog, system logging utility.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
int main(void) {
int i;
setlogmask (LOG_UPTO (LOG_NOTICE));
openlog ("exampleprog", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
for (i = 0;i<20000;i++)
{
syslog (LOG_NOTICE, "Program started by User %d", getuid ());
syslog (LOG_INFO, "A tree falls in a forest");
}
setlogmask (LOG_UPTO (LOG_INFO));
for (i = 0;i<20000;i++)
{
syslog (LOG_NOTICE, "Program started by User %d", getuid ());
syslog (LOG_INFO, "A tree falls in a forest");
}
closelog ();
return 0;
}
No comments:
Post a Comment