Logging error messages in a Daemon program



Hi,

I am converting an existing application into a daemon program. I have a
query on error message logging. Since the application creates daily
logs its does not use syslog, instead all message a logged in a log
file.

I am trying to figure out the best way to inform the user of an error,
under conditions where the application is not able to open/create a log
file.

One of the ways I found on the net is to re-direct it to /dev/console.
Are there any other ways of doing it?

Currently I am not closing stderr. Incase log file open fails all error
messages are directed to stderr. While running the daemon I redirect
stderr to a file.

What problems could arise on doing this? (other than losing messages
when stderr is not redirected)

Would help if I could some input on the above.

Thanks and Regards,
M Shetty

.



Relevant Pages

  • Logging error messages in a Daemon Program
    ... I am converting an existing application into a daemon program. ... query on error message logging. ... Currently I am not closing stderr. ... While running the daemon I redirect ...
    (comp.unix.programmer)
  • Re: redirect the output to a file
    ... you have two commands executed in sequence. ... That will cause all output from /make/ to stdout to be sent to ... error messages sent to stderr will only go to the screen. ... Will first redirect stderr to stdout, then send it all to /tee/. ...
    (comp.os.linux.misc)
  • Re: [Full-Disclosure] cmd.exe bug in win2k sp4 in "for" loop ... erratum
    ... " When you redirect a program's output, ... specifiy which output you want (STDOUT or stderr)." ... stdin is used for inputs, ...
    (Full-Disclosure)
  • Re: Redirecting STDERR
    ... > I have a script where I redirect STDERR to a file so that I can capture ... > redirect 'die' messages? ...
    (perl.beginners)
  • Re: StringIO and reopen
    ... StringIO) for a feature which seems rarely wanted (I cannot recall ... There is no way I am aware of to redirect a file descriptor to an in memory ... The problem with what you do here is that it changes the variable $stderr ... The safest seems indeed to redirect the IO to a pipe, have a background thread read from the pipe and store data in a String or StringIO and then execute the code whose output you want to catch. ...
    (comp.lang.ruby)