Logging

Hi

How to manage logging in an application.
Actually I am developing a Client-Server application in c/c++ and want to manage an optional logging in my application, but since prior I have never done ths activity.

Plz guide me.

thanks.

If the server needs to complain about possibly system-critical operations, you can use the syslog() call to have the syslogd process handle error information for your process.

Most logs are just written to a file descriptor, usually a text file opened in append mode, so you don't lose history. The log entry usually consists of a timestamp (date in date & time format) the username, an error or condition code and maybe an optional message.

You probably do not want to record everything that occurs - in other words your option to turn on logging (logging is usually a server thing) can be set to log at
different levels of severity of problem:

  1. all activities (for debugging maybe)
  2. from warnings up to fatal errors
  3. fatal errors.

Logging every little thing uses up system resources, so unless you are monitoring for compliance as in an audit log, go easy on how you set up logging activity levels.

thanks

but by 'optional logging' I mean that if I use the compilor option -DLOGFILE at compile time, the logging turns on and if I not use this the logging remains turn off, since I am writing log between

#ifdef LOGFILE
writeLog(...);
#endif

and this whole thing done at compile time, but I want to control it at run-time.