FileDocCategorySizeDatePackage
LogHandler.javaAPI DocGlassfish v2 API4751Fri May 04 22:33:16 BST 2007org.apache.tomcat.util.log

LogHandler

public class LogHandler extends Object
Log destination ( or channel ). This is the base class that will be extended by log handlers - tomcat uses util.qlog.QueueLogger, in future we'll use log4j or java.util.logger adapters. The base class writes to a (default) writer, and it can be used for very simple logging.
author
Anil Vijendran (akv@eng.sun.com)
author
Alex Chaffee (alex@jguru.com)
author
Ignacio J. Ortega (nacho@siapi.es)
author
Costin Manolache

Fields Summary
protected PrintWriter
sink
protected int
level
protected static PrintWriter
defaultSink
Constructors Summary
Methods Summary
public synchronized voidclose()
Close the log.

	this.sink = null;
    
public voidflush()
Flush the log.

	if( sink!=null)
	    sink.flush();
    
public intgetLevel()
Get the current verbosity level.

	return this.level;
    
public voidlog(java.lang.String prefix, java.lang.String msg, java.lang.Throwable t, int verbosityLevel)
Prints log message and stack trace. This method should be overriden by real logger implementations

param
prefix optional prefix.
param
message the message to log.
param
t the exception that was thrown.
param
verbosityLevel what type of message is this? (WARNING/DEBUG/INFO etc)


    
                    			   			     			     		      				      
           
		     
    
	if( sink==null ) return;
	// default implementation ( in case no real logging is set up  )
	if( verbosityLevel > this.level ) return;
	
	if (prefix != null) 
	    sink.println(prefix + ": " + msg );
	else 
	    sink.println(  msg );
	
	if( t!=null )
	    t.printStackTrace( sink );
    
public static voidsetDefaultSink(java.io.Writer w)
Set the default output stream that is used by all logging channels.

param
w the default output stream.


                 			        
         
	if( w instanceof PrintWriter )
	    defaultSink=(PrintWriter)w;
	else 
	    defaultSink = new PrintWriter(w);
    
public voidsetLevel(int level)
Set the verbosity level for this logger. This controls how the logs will be filtered.

param
level one of the verbosity level codes.

	this.level = level;