Search code examples
clinuxsyslog

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.


Solution

  • 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