org.mmbase.util.logging.log4j
Class Log4jImpl

java.lang.Object
  |
  +--org.apache.log4j.Category
        |
        +--org.mmbase.util.logging.log4j.Log4jImpl
All Implemented Interfaces:
org.apache.log4j.spi.AppenderAttachable, Logger

public final class Log4jImpl
extends org.apache.log4j.Category
implements Logger

This Logger implementation extends the Category class from the log4j project. It has the following extra functionality. First of all it uses the LoggerPriority class for Priority, and so has two extra priorities, namely 'trace' and 'service'. Further it instantiates one object of itself, named `STDERR' to which stderr will be redirected. Normally this will happen with priority `info' but Exceptions will get priorty `fatal'. It also has a static member method `configure', which calls the configure of DOMConfigurator, in this way log4j classes are used only here, and the rest of MMBase can use only `Logger'.

Author:
Michiel Meeuwissen

Fields inherited from class org.apache.log4j.Category
additive, DEFAULT_CONFIGURATION_FILE, DEFAULT_CONFIGURATION_KEY, DEFAULT_INIT_OVERRIDE_KEY, defaultHierarchy, hierarchy, name, parent, priority, resourceBundle
 
Method Summary
static void configure(java.lang.String s)
          Calls the configure method of DOMConfigurator, and redirect standard error to STDERR category.
static java.io.File getConfigurationFile()
           
static org.apache.log4j.Category getInstance(java.lang.String name)
          This method overrides Category.getInstance(java.lang.String) by supplying its own factory type as a parameter.
static Log4jImpl getLoggerInstance(java.lang.String name)
          As getInstance, but casted to Logger already.
 boolean isServiceEnabled()
          Returns true if for this category (Logger), a call to service (debug or trace) would do something.
 void service(java.lang.Object message)
          A new logging method that takes the SERVICE priority.
 void setLevel(Level p)
          If you want to override the level in the configuration file fixed for this category, you can do it with this method.
 void setPriority(Level p)
           
 void trace(java.lang.Object message)
          A new logging method that takes the TRACE priority.
 
Methods inherited from class org.apache.log4j.Category
addAppender, assert, callAppenders, debug, debug, error, error, exists, fatal, fatal, forcedLog, getAdditivity, getAllAppenders, getAppender, getChainedPriority, getCurrentCategories, getDefaultHierarchy, getHierarchy, getInstance, getInstance, getName, getPriority, getResourceBundle, getResourceBundleString, getRoot, info, info, isDebugEnabled, isEnabledFor, isInfoEnabled, l7dlog, l7dlog, log, log, log, removeAllAppenders, removeAppender, removeAppender, setAdditivity, setPriority, setResourceBundle, shutdown, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mmbase.util.logging.Logger
debug, error, fatal, info, isDebugEnabled, warn
 

Method Detail

getLoggerInstance

public static Log4jImpl getLoggerInstance(java.lang.String name)
As getInstance, but casted to Logger already. And the possible ClassCastException is caught.

configure

public static void configure(java.lang.String s)
Calls the configure method of DOMConfigurator, and redirect standard error to STDERR category.
Parameters:
s: - A string to the xml-configuration file. Can be absolute, or relative to the Logging configuration file.

getConfigurationFile

public static java.io.File getConfigurationFile()

setLevel

public void setLevel(Level p)
Description copied from interface: Logger
If you want to override the level in the configuration file fixed for this category, you can do it with this method. This could be usefull for example to switch on all debug logging when something has gone wrong.
Specified by:
setLevel in interface Logger
Following copied from interface: org.mmbase.util.logging.Logger
Parameters:
p - The level of the priority. One of the constants Level.TRACE, Level.DEBUG, Level.SERVICE, Level.INFO, Level.WARN, Level.ERROR or Level.FATAL.

setPriority

public void setPriority(Level p)
Specified by:
setPriority in interface Logger

getInstance

public static org.apache.log4j.Category getInstance(java.lang.String name)
This method overrides Category.getInstance(java.lang.String) by supplying its own factory type as a parameter.

trace

public final void trace(java.lang.Object message)
A new logging method that takes the TRACE priority.
Specified by:
trace in interface Logger
Following copied from interface: org.mmbase.util.logging.Logger
See Also:
Logger.debug(java.lang.Object)

service

public final void service(java.lang.Object message)
A new logging method that takes the SERVICE priority.
Specified by:
service in interface Logger

isServiceEnabled

public final boolean isServiceEnabled()
Description copied from interface: Logger
Returns true if for this category (Logger), a call to service (debug or trace) would do something.
Specified by:
isServiceEnabled in interface Logger


MMBase 2002