org.jboss.logging
Class DynamicLogger

java.lang.Object
  extended by org.jboss.logging.Logger
      extended by org.jboss.logging.DynamicLogger
All Implemented Interfaces:
Serializable

public class DynamicLogger
extends Logger

An extension of the JBoss Logger that adds a log() primitive that maps to a dynamically defined log level. TODO - Make sure serialization works correctly

Since:
4.0.3
Version:
$Revision: 1.1.2.3 $
Author:
Dimitris Andreadis
See Also:
Serialized Form

Field Summary
static int LOG_LEVEL_DEBUG
           
static int LOG_LEVEL_ERROR
           
static int LOG_LEVEL_FATAL
           
static int LOG_LEVEL_INFO
           
static int LOG_LEVEL_NONE
          The available log levels
static String[] LOG_LEVEL_STRINGS
          The available log level strings
static int LOG_LEVEL_TRACE
           
static int LOG_LEVEL_WARN
           
 
Fields inherited from class org.jboss.logging.Logger
LOG4J_PLUGIN_CLASS_NAME, loggerDelegate, PLUGIN_CLASS_PROP, pluginClass, pluginClassName
 
Constructor Summary
protected DynamicLogger(String name)
          Protected CTOR
 
Method Summary
static DynamicLogger getDynamicLogger(Class clazz)
          Create a DynamicLogger instance given the logger class.
static DynamicLogger getDynamicLogger(Class clazz, String suffix)
          Create a DynamicLogger instance given the logger class with the given suffix.
static DynamicLogger getDynamicLogger(String name)
          Create a DynamicLogger instance given the logger name.
static DynamicLogger getDynamicLogger(String name, String suffix)
          Create a DynamicLogger instance given the logger name with the given suffix.
 int getLogLevel()
          Gets the logLevel of the log() primitive
 String getLogLevelAsString()
          Gets the logLevel of the log() primitive in String form
 void log(Object message)
          Logs a message using dynamic log level
 void log(Object message, Throwable t)
          Logs a message and a throwable using dynamic log level
 void setLogLevel(int logLevel)
          Sets the logLevel for the log() primitive
 void setLogLevelAsString(String logLevelString)
          Sets the logLevel of the log() primitive
 
Methods inherited from class org.jboss.logging.Logger
debug, debug, error, error, fatal, fatal, getDelegatePlugin, getLogger, getLogger, getLogger, getLogger, getLoggerPlugin, getName, getPluginClassName, info, info, init, isDebugEnabled, isInfoEnabled, isTraceEnabled, setPluginClassName, trace, trace, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_LEVEL_NONE

public static final int LOG_LEVEL_NONE
The available log levels

See Also:
Constant Field Values

LOG_LEVEL_FATAL

public static final int LOG_LEVEL_FATAL
See Also:
Constant Field Values

LOG_LEVEL_ERROR

public static final int LOG_LEVEL_ERROR
See Also:
Constant Field Values

LOG_LEVEL_WARN

public static final int LOG_LEVEL_WARN
See Also:
Constant Field Values

LOG_LEVEL_INFO

public static final int LOG_LEVEL_INFO
See Also:
Constant Field Values

LOG_LEVEL_DEBUG

public static final int LOG_LEVEL_DEBUG
See Also:
Constant Field Values

LOG_LEVEL_TRACE

public static final int LOG_LEVEL_TRACE
See Also:
Constant Field Values

LOG_LEVEL_STRINGS

public static final String[] LOG_LEVEL_STRINGS
The available log level strings

Constructor Detail

DynamicLogger

protected DynamicLogger(String name)
Protected CTOR

Method Detail

getDynamicLogger

public static DynamicLogger getDynamicLogger(String name)
Create a DynamicLogger instance given the logger name.

Parameters:
name - the logger name

getDynamicLogger

public static DynamicLogger getDynamicLogger(String name,
                                             String suffix)
Create a DynamicLogger 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.

getDynamicLogger

public static DynamicLogger getDynamicLogger(Class clazz)
Create a DynamicLogger instance given the logger class. This simply calls create(clazz.getName()).

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

getDynamicLogger

public static DynamicLogger getDynamicLogger(Class clazz,
                                             String suffix)
Create a DynamicLogger 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.

setLogLevel

public void setLogLevel(int logLevel)
Sets the logLevel for the log() primitive

Parameters:
logLevel - between LOG_LEVEL_NONE and LOG_LEVEL_TRACE

getLogLevel

public int getLogLevel()
Gets the logLevel of the log() primitive

Returns:
the logLevel of the log() primitive

setLogLevelAsString

public void setLogLevelAsString(String logLevelString)
Sets the logLevel of the log() primitive

Parameters:
logLevelString - the log level in String form

getLogLevelAsString

public String getLogLevelAsString()
Gets the logLevel of the log() primitive in String form

Returns:
the logLevel of the log() primitive in String form

log

public void log(Object message)
Logs a message using dynamic log level

Parameters:
message - the message to log

log

public void log(Object message,
                Throwable t)
Logs a message and a throwable using dynamic log level

Parameters:
message - the message to log
t - the throwable to log


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