The is a special logging framework available in UNIX call as SYSLOG. In this example, we will see how can we log an INFO to syslog
#include <stdio.h>
#include <unistd.h>
#include <syslog.h>
int main(void) {
openlog("mySYSLOG", 0, LOG_USER);
syslog(LOG_INFO, "HELLO WORLD...LOG THIS MESSAGE");
closelog();
return 0;
}
First we have to include
<syslog.h> header file. Then we need to open a connection by using the
openlog function.Finally we need to log the message by using the
syslog function. The syslog function acts like the PRINTF function of C language.
Hope this helps.