Separating Log Messages

A Web Application using JSP's, Servlets, or other Java programs often needs to record information into log files. For example, it might want to keep track of the clients it is servicing or the database records it is updating. At the same time, there may be a need to insert debugging statements to find a bug, or as trace statemente in case an error occurs. It is good to separate this 'application' information from debugging/trace information.

One way to do this is to put these two sets of information into different log files. There is a out.log file and an err.log file. System.out.println( ) statements get recorded in the out.log file, and System.err.println( ) statements get recorded in the err.log file. It might be useful, therefore, to use System.out.println( ) for information that relates to the application, and System.err.println( ) for debugging/trace information - so you can refer to them separately.

Here is an example of a JSP that has both times of statements:

   System.out.println("this goes to out.log");
   System.err.println("this goes to err.log");
   out.println("This is written to the browser screen <BR>");