Where are syslog logs stored?

Hello,

As you know, there is syslog library in C. It is supposed to keep logs under /var/log/ directory. I’ve been trying to find where the user logs get stored in Manjaro but have been unsuccessful finding them so far. I tried using journalctl but couldn’t find anything there either.

If you’re using systemd-journald (which Manjaro does), the logs are stored in /var/log/journal/.

it seems to me that C interface syslog logs to nowhere. I just can’t find it.

On my machine /dev/log is a symlink to /run/systemd/journal/dev-log, just as expected. So how are you looking for the messages?

I am inspecting the files under /var/log/journal with grep. I also used journalctl command to see if there are any logs. But I wasn’t able to find anything that was logged by my program.

journald uses a binary format, so you should use journalctl. You can run journalctl -f, which will continuously emit log messages as they come in, and then you can start your program to see if they appear there.

I already did that, they don’'t.

The following works for me:

#include <syslog.h>

int main()
{
	openlog("myprog", 0, LOG_USER);
	syslog(LOG_INFO, "hello world\n");
	closelog();

	return 0;
}

journalctl shows

jan [...] myprog[12907]: hello world

strace shows it connecting to the /dev/log UNIX domain socket as expected:

socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 3
connect(3, {sa_family=AF_UNIX, sun_path="/dev/log"}, 110) = 0
sendto(3, "<14>Jan [...] myprog: hell"..., 40, MSG_NOSIGNAL, NULL, 0) = 40
close(3)                                = 0

I tried yours and it indeed worked. Here is my program, can you tell me what’s wrong with it?

#include <syslog.h>

int main()
    setlogmask (LOG_UPTO (LOG_WARNING));

    openlog ("exampleprog", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);

    syslog (LOG_NOTICE, "Program started by User");
    syslog (LOG_INFO, "A tree falls in a forest");
    closelog ();

   return 0;
}

strace doesn’t show sendto function being called.

socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 3
connect(3, {sa_family=AF_UNIX, sun_path="/dev/log"}, 110) = 0
close(3)                                = 0
exit_group(0)                           = ?

Thanks a lot by the way,

This is the problem. This allows only LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.