Results 1 to 2 of 2

Thread: write a system log for admins with C

  1. #1
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,125
    Distro
    Ubuntu 10.04 Lucid Lynx

    Question write a system log for admins with C

    Hi All,
    I want to write errors in my program to the local 7 of syslog.
    Im reading:
    http://www.linuxselfhelp.com/gnu/gli...r/libc_18.html
    but what I really need is some specific examples.
    I'm not really sure how writing to a syslog is different than writing to a file?
    ~Conradin~

  2. #2
    Join Date
    Oct 2011
    Beans
    33

    Re: write a system log for admins with C

    Quote Originally Posted by conradin View Post
    Hi All,
    I want to write errors in my program to the local 7 of syslog.
    Im reading:
    http://www.linuxselfhelp.com/gnu/gli...r/libc_18.html
    but what I really need is some specific examples.
    I'm not really sure how writing to a syslog is different than writing to a file?
    Surely you were able to reference the examples given in the link you provided?

    Here's a simple example:
    Code:
    #include <syslog.h>
    
    int main()
    {
        openlog("foo_app", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL7);
    
        syslog(LOG_INFO, "Using syslog is easy.");
    
        closelog();
    
        return 0;
    }
    The string passed to syslog() can contain any message you desire.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •