FileDocCategorySizeDatePackage
Jdk14Logger.javaAPI DocAndroid 1.5 API8317Wed May 06 22:41:10 BST 2009org.apache.commons.logging.impl

Jdk14Logger

public class Jdk14Logger extends Object implements Serializable, Log

Implementation of the org.apache.commons.logging.Log interface that wraps the standard JDK logging mechanisms that were introduced in the Merlin release (JDK 1.4).

author
Scott Sanders
author
Berin Loritsch
author
Peter Donald
version
$Revision: 370652 $ $Date: 2006-01-19 22:23:48 +0000 (Thu, 19 Jan 2006) $

Fields Summary
protected static final Level
dummyLevel
This member variable simply ensures that any attempt to initialise this class in a pre-1.4 JVM will result in an ExceptionInInitializerError. It must not be private, as an optimising compiler could detect that it is not used and optimise it away.
protected transient Logger
logger
The underlying Logger implementation we are using.
protected String
name
The name of the logger we are wrapping.
Constructors Summary
public Jdk14Logger(String name)
Construct a named instance of this Logger.

param
name Name of the logger to be constructed


    // ----------------------------------------------------------- Constructors


                         
       

        this.name = name;
        logger = getLogger();

    
Methods Summary
public voiddebug(java.lang.Object message)
Logs a message with java.util.logging.Level.FINE.

param
message to log
see
org.apache.commons.logging.Log#debug(Object)

        log(Level.FINE, String.valueOf(message), null);
    
public voiddebug(java.lang.Object message, java.lang.Throwable exception)
Logs a message with java.util.logging.Level.FINE.

param
message to log
param
exception log this cause
see
org.apache.commons.logging.Log#debug(Object, Throwable)

        log(Level.FINE, String.valueOf(message), exception);
    
public voiderror(java.lang.Object message)
Logs a message with java.util.logging.Level.SEVERE.

param
message to log
see
org.apache.commons.logging.Log#error(Object)

        log(Level.SEVERE, String.valueOf(message), null);
    
public voiderror(java.lang.Object message, java.lang.Throwable exception)
Logs a message with java.util.logging.Level.SEVERE.

param
message to log
param
exception log this cause
see
org.apache.commons.logging.Log#error(Object, Throwable)

        log(Level.SEVERE, String.valueOf(message), exception);
    
public voidfatal(java.lang.Object message)
Logs a message with java.util.logging.Level.SEVERE.

param
message to log
see
org.apache.commons.logging.Log#fatal(Object)

        log(Level.SEVERE, String.valueOf(message), null);
    
public voidfatal(java.lang.Object message, java.lang.Throwable exception)
Logs a message with java.util.logging.Level.SEVERE.

param
message to log
param
exception log this cause
see
org.apache.commons.logging.Log#fatal(Object, Throwable)

        log(Level.SEVERE, String.valueOf(message), exception);
    
public java.util.logging.LoggergetLogger()
Return the native Logger instance we are using.

        if (logger == null) {
            logger = Logger.getLogger(name);
        }
        return (logger);
    
public voidinfo(java.lang.Object message)
Logs a message with java.util.logging.Level.INFO.

param
message to log
see
org.apache.commons.logging.Log#info(Object)

        log(Level.INFO, String.valueOf(message), null);
    
public voidinfo(java.lang.Object message, java.lang.Throwable exception)
Logs a message with java.util.logging.Level.INFO.

param
message to log
param
exception log this cause
see
org.apache.commons.logging.Log#info(Object, Throwable)

        log(Level.INFO, String.valueOf(message), exception);
    
public booleanisDebugEnabled()
Is debug logging currently enabled?

        return (getLogger().isLoggable(Level.FINE));
    
public booleanisErrorEnabled()
Is error logging currently enabled?

        return (getLogger().isLoggable(Level.SEVERE));
    
public booleanisFatalEnabled()
Is fatal logging currently enabled?

        return (getLogger().isLoggable(Level.SEVERE));
    
public booleanisInfoEnabled()
Is info logging currently enabled?

        return (getLogger().isLoggable(Level.INFO));
    
public booleanisTraceEnabled()
Is trace logging currently enabled?

        return (getLogger().isLoggable(Level.FINEST));
    
public booleanisWarnEnabled()
Is warn logging currently enabled?

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



    // --------------------------------------------------------- Public Methods

              

        Logger logger = getLogger();
        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];
                cname=caller.getClassName();
                method=caller.getMethodName();
            }
            if( ex==null ) {
                logger.logp( level, cname, method, msg );
            } else {
                logger.logp( level, cname, method, msg, ex );
            }
        }

    
public voidtrace(java.lang.Object message)
Logs a message with java.util.logging.Level.FINEST.

param
message to log
see
org.apache.commons.logging.Log#trace(Object)

        log(Level.FINEST, String.valueOf(message), null);
    
public voidtrace(java.lang.Object message, java.lang.Throwable exception)
Logs a message with java.util.logging.Level.FINEST.

param
message to log
param
exception log this cause
see
org.apache.commons.logging.Log#trace(Object, Throwable)

        log(Level.FINEST, String.valueOf(message), exception);
    
public voidwarn(java.lang.Object message)
Logs a message with java.util.logging.Level.WARNING.

param
message to log
see
org.apache.commons.logging.Log#warn(Object)

        log(Level.WARNING, String.valueOf(message), null);
    
public voidwarn(java.lang.Object message, java.lang.Throwable exception)
Logs a message with java.util.logging.Level.WARNING.

param
message to log
param
exception log this cause
see
org.apache.commons.logging.Log#warn(Object, Throwable)

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