Maverick
Maverick

Reputation: 2022

where syslog store error messages

syslog() generates a log message

syslog(LOG_ERR, "%s failed: %d (%m)", str, errno); syslog(LOG_NOTICE, "%s failed: %d (%m)", str, errno); syslog(LOG_INFO,"%s",str);

where does it store this info?

I can not find any file in the server by the name of LOG_ERR, LOG_NOTICE,LOG_INFO.

Please suggest.

Upvotes: 2

Views: 5677

Answers (2)

TOC
TOC

Reputation: 4446

Under Linux you can find them here : /var/log/syslog, if you run this simple program:

#include <syslog.h>

int main(int argc, char **argv)
{
        /* Various syslog messages */
        syslog (LOG_CRIT, "%s", "That's critic");
        syslog(LOG_ALERT, "An alert\n");
        syslog(LOG_ERR, "Error on this DAEMON\n");

        return 0;
}

and open a terminal and run this:

toc@UnixServer:/var/log$ tail -f syslog

You should see something like this:

Aug 18 08:42:21 TarekServer SYSLOG: That's critic
Aug 18 08:42:21 TarekServer SYSLOG: An alert
Aug 18 08:42:21 TarekServer SYSLOG: Error on this DAEMON

Upvotes: 2

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798526

They get dumped into the syslog buffer where syslogd/rsyslogd picks them up and puts them in the appropriate locations as determined by its configuration in /etc.

Upvotes: 1

Related Questions