DirectJDKLog.javaAPI DocApache Tomcat 6.0.146275Fri Jul 20 04:20:36 BST 2007org.apache.juli.logging


public class DirectJDKLog extends Object implements Log
Hardcoded java.util.logging commons-logging implementation. In addition, it curr

Fields Summary
public Logger
private static final String
Alternate config reader and console format
private static final String
Constructors Summary
public DirectJDKLog(String name)

        if( System.getProperty("java.util.logging.config.class") ==null  &&
                System.getProperty("java.util.logging.config.file") ==null ) {
            // default configuration - it sucks. Let's override at least the 
            // formatter for the console
            try {
            } catch( Throwable t ) {                
            try {
                Formatter fmt=(Formatter)Class.forName(SIMPLE_FMT).newInstance();
                // it is also possible that the user modifed jre/lib/ - 
                // but that's really stupid in most cases
                Logger root=Logger.getLogger("");
                Handler handlers[]=root.getHandlers();
                for( int i=0; i< handlers.length; i++ ) {
                    // I only care about console - that's what's used in default config anyway
                    if( handlers[i] instanceof  ConsoleHandler ) {
            } catch( Throwable t ) {
                // maybe it wasn't included - the ugly default will be used.
Methods Summary
public final voiddebug(java.lang.Object message)

        log(Level.FINE, String.valueOf(message), null);
public final voiddebug(java.lang.Object message, java.lang.Throwable t)

        log(Level.FINE, String.valueOf(message), t);
public final voiderror(java.lang.Object message)

        log(Level.SEVERE, String.valueOf(message), null);
public final voiderror(java.lang.Object message, java.lang.Throwable t)

        log(Level.SEVERE, String.valueOf(message), t);
public final voidfatal(java.lang.Object message)

        log(Level.SEVERE, String.valueOf(message), null);
public final voidfatal(java.lang.Object message, java.lang.Throwable t)

        log(Level.SEVERE, String.valueOf(message), t);
static LoggetInstance(java.lang.String name)

        return new DirectJDKLog( name );
public final voidinfo(java.lang.Object message)

        log(Level.INFO, String.valueOf(message), null);
public final voidinfo(java.lang.Object message, java.lang.Throwable t)

        log(Level.INFO, String.valueOf(message), t);
public final booleanisDebugEnabled()

        return logger.isLoggable(Level.FINE);
public final booleanisErrorEnabled()

        return logger.isLoggable(Level.SEVERE);
public final booleanisFatalEnabled()

        return logger.isLoggable(Level.SEVERE);
public final booleanisInfoEnabled()

        return logger.isLoggable(Level.INFO);
public final booleanisTraceEnabled()

        return logger.isLoggable(Level.FINER);
public final booleanisWarnEnabled()

        return logger.isLoggable(Level.WARNING); 
private voidlog(java.util.logging.Level level, java.lang.String msg, java.lang.Throwable ex)

        if (logger.isLoggable(level)) {
            // Hack (?) to get the stack trace.
            Throwable dummyException=new Throwable();
            StackTraceElement locations[]=dummyException.getStackTrace();
            // Caller will be the third element
            String cname="unknown";
            String method="unknown";
            if( locations!=null && locations.length >2 ) {
                StackTraceElement caller=locations[2];
            if( ex==null ) {
                logger.logp( level, cname, method, msg );
            } else {
                logger.logp( level, cname, method, msg, ex );
static voidrelease()

public final voidtrace(java.lang.Object message)

        log(Level.FINER, String.valueOf(message), null);
public final voidtrace(java.lang.Object message, java.lang.Throwable t)

        log(Level.FINER, String.valueOf(message), t);
public final voidwarn(java.lang.Object message)

        log(Level.WARNING, String.valueOf(message), null);
public final voidwarn(java.lang.Object message, java.lang.Throwable t)

        log(Level.WARNING, String.valueOf(message), t);