站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 common API Documentation 英文版文档

Logger (JBoss/Common API) - JBoss 4.0.1 sp1 common API Documentation 英文版文档


org.jboss.logging
Class Logger

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

public class Logger
extends Object
implements 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.

Version:
$Revision: 1.11 $
Author:
Scott.Stark@jboss.org, Jason Dillon, Sacha Labourey
See Also:
isTraceEnabled(), trace(Object), trace(Object,Throwable), Serialized Form

Field Summary
protected static String LOG4J_PLUGIN_CLASS_NAME
          The default LoggerPlugin implementation is log4j
protected  LoggerPlugin loggerDelegate
           
protected static String PLUGIN_CLASS_PROP
          The system property to look for an externalized LoggerPlugin implementation class
protected static Class pluginClass
          The LoggerPlugin implementation class to use
protected static String pluginClassName
          The class name of the LoggerPlugin implementation class to use
 
Constructor Summary
protected Logger(String name)
          Creates new Logger the given logger name.
 
Method Summary
 void debug(Object message)
          Issue a log msg with a level of DEBUG.
 void debug(Object message, Throwable t)
          Issue a log msg and throwable with a level of DEBUG.
 void error(Object message)
          Issue a log msg with a level of ERROR.
 void error(Object message, Throwable t)
          Issue a log msg and throwable with a level of ERROR.
 void fatal(Object message)
          Issue a log msg with a level of FATAL.
 void fatal(Object message, Throwable t)
          Issue a log msg and throwable with a level of FATAL.
protected static LoggerPlugin getDelegatePlugin(String name)
           
static Logger getLogger(Class clazz)
          Create a Logger instance given the logger class.
static Logger getLogger(Class clazz, String suffix)
          Create a Logger instance given the logger class with the given suffix.
static Logger getLogger(String name)
          Create a Logger instance given the logger name.
static Logger getLogger(String name, String suffix)
          Create a Logger instance given the logger name with the given suffix.
 LoggerPlugin getLoggerPlugin()
           
 String getName()
          Return the name of this logger.
static String getPluginClassName()
          The LoggerPlugin implementation class name in use
 void info(Object message)
          Issue a log msg with a level of INFO.
 void info(Object message, 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(String pluginClassName)
          Set the LoggerPlugin implementation class name in use
 void trace(Object message)
          Issue a log msg with a level of TRACE.
 void trace(Object message, Throwable t)
          Issue a log msg and throwable with a level of TRACE.
 void warn(Object message)
          Issue a log msg with a level of WARN.
 void warn(Object message, 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 String PLUGIN_CLASS_PROP
The system property to look for an externalized LoggerPlugin implementation class


LOG4J_PLUGIN_CLASS_NAME

protected static final String LOG4J_PLUGIN_CLASS_NAME
The default LoggerPlugin implementation is log4j

See Also:
Constant Field Values

pluginClass

protected static Class pluginClass
The LoggerPlugin implementation class to use


pluginClassName

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


loggerDelegate

protected transient LoggerPlugin loggerDelegate
Constructor Detail

Logger

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

Parameters:
name - the logger name.
Method Detail

getPluginClassName

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

Returns:
LoggerPlugin implementation class name

setPluginClassName

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

Parameters:
pluginClassName - the LoggerPlugin implementation class name

getName

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

Returns:
The name of this logger.

getLoggerPlugin

public LoggerPlugin 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(Object message)
Issue a log msg with a level of TRACE. Invokes log.log(XLevel.TRACE, message);


trace

public void trace(Object message,
                  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(Object message)
Issue a log msg with a level of DEBUG. Invokes log.log(Level.DEBUG, message);


debug

public void debug(Object message,
                  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(Object message)
Issue a log msg with a level of INFO. Invokes log.log(Level.INFO, message);


info

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


warn

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


warn

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


error

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


error

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


fatal

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


fatal

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


getLogger

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

Parameters:
name - the logger name

getLogger

public static Logger getLogger(String name,
                               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 getLogger(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 getLogger(Class clazz,
                               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 getDelegatePlugin(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.



Copyright © 2002 JBoss Group, LLC. All Rights Reserved.