org.jboss.logging
Class Logger

java.lang.Object
  extended byorg.jboss.logging.Logger
All Implemented Interfaces:
java.io.Serializable

public class Logger
extends java.lang.Object
implements java.io.Serializable

Logger wrapper that tries to dynamically load a log4j class to determine if log4j is available in the VM. If it is the case, a log4j delegate is built and used. In the contrary, a null logger is used. This class cannot directly reference log4j classes otherwise the JVM will try to load it and make it fail. To set

Only exposes the relevent factory and logging methods.

See Also:
isTraceEnabled(), trace(Object), trace(Object,Throwable), Serialized Form

Field Summary
protected static java.lang.String LOG4J_PLUGIN_CLASS_NAME
          The default LoggerPlugin implementation is log4j
protected  LoggerPlugin (src) loggerDelegate
           
protected static java.lang.String PLUGIN_CLASS_PROP
          The system property to look for an externalized LoggerPlugin implementation class
protected static java.lang.Class pluginClass
          The LoggerPlugin implementation class to use
protected static java.lang.String pluginClassName
          The class name of the LoggerPlugin implementation class to use
 
Constructor Summary
protected Logger(java.lang.String name)
          Creates new Logger the given logger name.
 
Method Summary
 void debug(java.lang.Object message)
          Issue a log msg with a level of DEBUG.
 void debug(java.lang.Object message, java.lang.Throwable t)
          Issue a log msg and throwable with a level of DEBUG.
 void error(java.lang.Object message)
          Issue a log msg with a level of ERROR.
 void error(java.lang.Object message, java.lang.Throwable t)
          Issue a log msg and throwable with a level of ERROR.
 void fatal(java.lang.Object message)
          Issue a log msg with a level of FATAL.
 void fatal(java.lang.Object message, java.lang.Throwable t)
          Issue a log msg and throwable with a level of FATAL.
protected static LoggerPlugin (src) getDelegatePlugin(java.lang.String name)
           
static Logger (src) getLogger(java.lang.Class clazz)
          Create a Logger instance given the logger class.
static Logger (src) getLogger(java.lang.Class clazz, java.lang.String suffix)
          Create a Logger instance given the logger class with the given suffix.
static Logger (src) getLogger(java.lang.String name)
          Create a Logger instance given the logger name.
static Logger (src) getLogger(java.lang.String name, java.lang.String suffix)
          Create a Logger instance given the logger name with the given suffix.
 LoggerPlugin (src) getLoggerPlugin()
           
 java.lang.String getName()
          Return the name of this logger.
static java.lang.String getPluginClassName()
          The LoggerPlugin implementation class name in use
 void info(java.lang.Object message)
          Issue a log msg with a level of INFO.
 void info(java.lang.Object message, java.lang.Throwable t)
          Issue a log msg and throwable with a level of INFO.
protected static void init()
          Initialize the LoggerPlugin class to use as the delegate to the logging system.
 boolean isDebugEnabled()
          Check to see if the TRACE level is enabled for this logger.
 boolean isInfoEnabled()
          Check to see if the INFO level is enabled for this logger.
 boolean isTraceEnabled()
          Check to see if the TRACE level is enabled for this logger.
static void setPluginClassName(java.lang.String pluginClassName)
          Set the LoggerPlugin implementation class name in use
 void trace(java.lang.Object message)
          Issue a log msg with a level of TRACE.
 void trace(java.lang.Object message, java.lang.Throwable t)
          Issue a log msg and throwable with a level of TRACE.
 void warn(java.lang.Object message)
          Issue a log msg with a level of WARN.
 void warn(java.lang.Object message, java.lang.Throwable t)
          Issue a log msg and throwable with a level of WARN.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLUGIN_CLASS_PROP

protected static java.lang.String PLUGIN_CLASS_PROP
The system property to look for an externalized LoggerPlugin implementation class


LOG4J_PLUGIN_CLASS_NAME

protected static final java.lang.String LOG4J_PLUGIN_CLASS_NAME
The default LoggerPlugin implementation is log4j

See Also:
Constant Field Values (src)

pluginClass

protected static java.lang.Class pluginClass
The LoggerPlugin implementation class to use


pluginClassName

protected static java.lang.String pluginClassName
The class name of the LoggerPlugin implementation class to use


loggerDelegate

protected transient LoggerPlugin (src)  loggerDelegate
Constructor Detail

Logger

protected Logger(java.lang.String name)
Creates new Logger the given logger name.

Parameters:
name - the logger name.
Method Detail

getPluginClassName

public static java.lang.String getPluginClassName()
The LoggerPlugin implementation class name in use

Returns:
LoggerPlugin implementation class name

setPluginClassName

public static void setPluginClassName(java.lang.String pluginClassName)
Set the LoggerPlugin implementation class name in use

Parameters:
pluginClassName - the LoggerPlugin implementation class name

getName

public java.lang.String getName()
Return the name of this logger.

Returns:
The name of this logger.

getLoggerPlugin

public LoggerPlugin (src)  getLoggerPlugin()

isTraceEnabled

public boolean isTraceEnabled()
Check to see if the TRACE level is enabled for this logger.

Returns:
true if a trace(Object) method invocation would pass the msg to the configured appenders, false otherwise.

trace

public void trace(java.lang.Object message)
Issue a log msg with a level of TRACE. Invokes log.log(XLevel.TRACE, message);


trace

public void trace(java.lang.Object message,
                  java.lang.Throwable t)
Issue a log msg and throwable with a level of TRACE. Invokes log.log(XLevel.TRACE, message, t);


isDebugEnabled

public boolean isDebugEnabled()
Check to see if the TRACE level is enabled for this logger.

Returns:
true if a trace(Object) method invocation would pass the msg to the configured appenders, false otherwise.

debug

public void debug(java.lang.Object message)
Issue a log msg with a level of DEBUG. Invokes log.log(Level.DEBUG, message);


debug

public void debug(java.lang.Object message,
                  java.lang.Throwable t)
Issue a log msg and throwable with a level of DEBUG. Invokes log.log(Level.DEBUG, message, t);


isInfoEnabled

public boolean isInfoEnabled()
Check to see if the INFO level is enabled for this logger.

Returns:
true if a info(Object) method invocation would pass the msg to the configured appenders, false otherwise.

info

public void info(java.lang.Object message)
Issue a log msg with a level of INFO. Invokes log.log(Level.INFO, message);


info

public void info(java.lang.Object message,
                 java.lang.Throwable t)
Issue a log msg and throwable with a level of INFO. Invokes log.log(Level.INFO, message, t);


warn

public void warn(java.lang.Object message)
Issue a log msg with a level of WARN. Invokes log.log(Level.WARN, message);


warn

public void warn(java.lang.Object message,
                 java.lang.Throwable t)
Issue a log msg and throwable with a level of WARN. Invokes log.log(Level.WARN, message, t);


error

public void error(java.lang.Object message)
Issue a log msg with a level of ERROR. Invokes log.log(Level.ERROR, message);


error

public void error(java.lang.Object message,
                  java.lang.Throwable t)
Issue a log msg and throwable with a level of ERROR. Invokes log.log(Level.ERROR, message, t);


fatal

public void fatal(java.lang.Object message)
Issue a log msg with a level of FATAL. Invokes log.log(Level.FATAL, message);


fatal

public void fatal(java.lang.Object message,
                  java.lang.Throwable t)
Issue a log msg and throwable with a level of FATAL. Invokes log.log(Level.FATAL, message, t);


getLogger

public static Logger (src)  getLogger(java.lang.String name)
Create a Logger instance given the logger name.

Parameters:
name - the logger name

getLogger

public static Logger (src)  getLogger(java.lang.String name,
                               java.lang.String suffix)
Create a Logger instance given the logger name with the given suffix.

This will include a logger seperator between classname and suffix

Parameters:
name - The logger name
suffix - A suffix to append to the classname.

getLogger

public static Logger (src)  getLogger(java.lang.Class clazz)
Create a Logger instance given the logger class. This simply calls create(clazz.getName()).

Parameters:
clazz - the Class whose name will be used as the logger name

getLogger

public static Logger (src)  getLogger(java.lang.Class clazz,
                               java.lang.String suffix)
Create a Logger instance given the logger class with the given suffix.

This will include a logger seperator between classname and suffix

Parameters:
clazz - The Class whose name will be used as the logger name.
suffix - A suffix to append to the classname.

getDelegatePlugin

protected static LoggerPlugin (src)  getDelegatePlugin(java.lang.String name)

init

protected static void init()
Initialize the LoggerPlugin class to use as the delegate to the logging system. This first checks to see if a pluginClassName has been specified via the setPluginClassName(String) method, then the PLUGIN_CLASS_PROP system property and finally the LOG4J_PLUGIN_CLASS_NAME default. If the LoggerPlugin implementation class cannot be loaded the default NullLoggerPlugin will be used.