How to use syslog() in c to get logging from my program into system logs?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • afrah
    New Member
    • Jul 2010
    • 12

    How to use syslog() in c to get logging from my program into system logs?

    How to use syslog() for logging from a my C program
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2


    Hope this will help you...

    Comment

    • afrah
      New Member
      • Jul 2010
      • 12

      #3
      Thanks for the link but i already had a look at this link nd tried the code of the code of the example.
      But I cud not figure out where to check if this is working or not.
      I am not getting any log information on console when i run my binary with the example code in it.

      Comment

      • ashitpro
        Recognized Expert Contributor
        • Aug 2007
        • 542

        #4
        You will not get anything on console..

        Look at the end of "/var/log/messages" (This should be specified in /etc/syslog.conf)
        It should go there.

        Also make sure that syslog service is started...

        Comment

        • afrah
          New Member
          • Jul 2010
          • 12

          #5
          Thanks yes I found out Its going there.
          I restarted the syslog service.
          I have to somehow attach my Programs logging levels to the syslog() logging level so that the alerts from my code go into syslog().
          Any suggestion on this issue.

          Comment

          • ashitpro
            Recognized Expert Contributor
            • Aug 2007
            • 542

            #6
            I am not sure if I understood you correctly.

            Can't you use
            syslog (LOG_NOTICE, "My alerts");
            in your code, wherever you may require?

            Comment

            • afrah
              New Member
              • Jul 2010
              • 12

              #7
              Thanks I tried it nd It worked this way. :)
              But I am still not sure will this suffice my need for the entire log levels in my code but till now its good.
              Thanks a lot.

              Comment

              • Oralloy
                Recognized Expert Contributor
                • Jun 2010
                • 988

                #8
                @afrah,

                I don't know if your release has the concept of console windows and plain terminal windows.

                On my Solaris box, system messages are sent to console windows only - plain terminal windows do not get the messages.

                Cheers!
                Oralloy

                Comment

                Working...