Find the answer to your Linux question:
Results 1 to 3 of 3
Hello, I am writing some code right now and I am thinking it would be grate to create some log file and send to it error/warning messages. Is there any ...
  1. #1
    Just Joined!
    Join Date
    Jun 2006
    Location
    Krakow, Poland
    Posts
    5

    create and use log file with C

    Hello,
    I am writing some code right now and I am thinking it would be grate to create some log file and send to it error/warning messages. Is there any common pattern to implement this solution? How can I easily get log directory name, create this file and send messages from C??

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    I don't know what you mean by "get log directory name", but for your other questions, do this at the command line:
    Code:
    man fopen
    man fwrite
    and all will be revealed.

  3. #3
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    If you just want to print warnings or errors to the user, you can just print to stderr and let him redirect it as he pleases.

    If you want to use a system logfile, you can use the syslog() function. Run the command "man 3 syslog" for more information.
    DISTRO=Arch
    Registered Linux User #388732

Posting Permissions

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