opc0de opc0de - 3 months ago 26
C Question

Where does linux store my syslog?

I wrote a simple test application to log something in a log file. I am using linux mint and after the application executes I try to view the log using this command:

tail -n 100 /var/log/messages


but the file messages does not exist neither tested or something. Below you can find my code. Maybe I am doing something wrong, the file isn't stored there or I need to enable logging in linux mint.

#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>

void init_log()
{
setlogmask(LOG_UPTO(LOG_NOTICE));
openlog("testd",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
}

int main(void) {

init_log();
printf("Session started!");
syslog(LOG_NOTICE, "Session started!!");
closelog();

return EXIT_SUCCESS;
}

Answer

On my Ubuntu machine, I can see the output at /var/log/syslog.

As noted by others, your syslog() output would be logged by the /var/log/syslog file.
You can see system, user, and other logs at /var/log.

For more details: here's an interesting link.

Comments