org.apache.tomcat.util.log
public class: LogHandler [javadoc |
source]
java.lang.Object
org.apache.tomcat.util.log.LogHandler
Direct Known Subclasses:
CommonLogHandler
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
Field Summary |
---|
protected PrintWriter | sink | |
protected int | level | |
protected static PrintWriter | defaultSink | |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from org.apache.tomcat.util.log.LogHandler Detail: |
public synchronized void close() {
this.sink = null;
}
|
public void flush() {
if( sink!=null)
sink.flush();
}
|
public int getLevel() {
return this.level;
}
Get the current verbosity level. |
public void log(String prefix,
String msg,
Throwable t,
int verbosityLevel) {
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 );
}
Prints log message and stack trace.
This method should be overriden by real logger implementations |
public static void setDefaultSink(Writer w) {
if( w instanceof PrintWriter )
defaultSink=(PrintWriter)w;
else
defaultSink = new PrintWriter(w);
}
Set the default output stream that is used by all logging
channels. |
public void setLevel(int level) {
this.level = level;
}
Set the verbosity level for this logger. This controls how the
logs will be filtered. |