org.mmbase.util.logging.log4j
Class Log4jImpl

java.lang.Object
  extended by org.apache.log4j.Category
      extended by org.apache.log4j.Logger
          extended by org.mmbase.util.logging.log4j.Log4jImpl
All Implemented Interfaces:
AppenderAttachable, Logger

public final class Log4jImpl
extends Logger
implements Logger

This Logger implementation extends the Logger class from the log4j project (version >= 1.2). It has the following extra functionality. First of all it uses the LoggerLevel class for Level, 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

Field Summary
 
Fields inherited from class org.apache.log4j.Category
additive, level, name, parent, repository, resourceBundle
 
Constructor Summary
protected Log4jImpl(String name)
          Constructor, like the constructor of Logger.
 
Method Summary
static void configure(String s)
          Calls the configure method of DOMConfigurator, and redirect standard error to STDERR category.
protected static void doConfigure(File f)
          Performs the actual parsing of the log4j configuration file and handles the errors
protected static void doConfigure(InputStream i)
           
static Category getInstance(String name)
          Deprecated. Use getLogger(java.lang.String)
static Logger getLogger(String name)
           
static Log4jImpl getLoggerInstance(String name)
          As getLogger, but cast to MMBase Logger already.
static MDC getMDC()
           
 boolean isEnabledFor(Level l)
           
 boolean isServiceEnabled()
          Returns true if for this category (Logger), a call to service (or debug or trace) would do something.
 boolean isTraceEnabled()
          Returns true if for this category (Logger), a call to trace would do something.
 void service(Object message)
          A new logging method that takes the SERVICE priority.
 void service(Object message, Throwable t)
           
 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.
static void shutdown()
           
 void trace(Object message)
          A new logging method that takes the TRACE priority.
 void trace(Object message, Throwable t)
           
 
Methods inherited from class org.apache.log4j.Logger
getLogger, getLogger, getRootLogger
 
Methods inherited from class org.apache.log4j.Category
addAppender, assertLog, callAppenders, debug, debug, error, error, exists, fatal, fatal, forcedLog, getAdditivity, getAllAppenders, getAppender, getChainedPriority, getCurrentCategories, getDefaultHierarchy, getEffectiveLevel, getHierarchy, getInstance, getLevel, getLoggerRepository, getName, getParent, getPriority, getResourceBundle, getResourceBundleString, getRoot, info, info, isAttached, isDebugEnabled, isEnabledFor, isInfoEnabled, l7dlog, l7dlog, log, log, log, removeAllAppenders, removeAppender, removeAppender, setAdditivity, setLevel, setPriority, setResourceBundle, 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, debug, error, error, fatal, fatal, info, info, isDebugEnabled, warn, warn
 

Constructor Detail

Log4jImpl

protected Log4jImpl(String name)
Constructor, like the constructor of Logger.

Method Detail

getLoggerInstance

public static Log4jImpl getLoggerInstance(String name)
As getLogger, but cast to MMBase Logger already. And the possible ClassCastException is caught.


getMDC

public static MDC getMDC()

configure

public static void configure(String s)
Calls the configure method of DOMConfigurator, and redirect standard error to STDERR category. It also starts up the FileWatcher. The 'configureAndWatch' method of DOMConfigurator used to be used, but it is not feasible anymore because 1. cannot give the repository then. 2. Cannot log the happening on normal way.

Parameters:
s - A string to the xml-configuration file. Can be absolute, or relative to the Logging configuration file.

doConfigure

protected static void doConfigure(InputStream i)

doConfigure

protected static void doConfigure(File f)
Performs the actual parsing of the log4j configuration file and handles the errors


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
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.

getInstance

public static Category getInstance(String name)
Deprecated. Use getLogger(java.lang.String)

This method overrides Category.getInstance(java.lang.String) by supplying its own factory type as a parameter.


getLogger

public static Logger getLogger(String name)

trace

public final void trace(Object message)
A new logging method that takes the TRACE priority.

Specified by:
trace in interface Logger
Overrides:
trace in class Logger
See Also:
Logger.debug(Object)

trace

public final void trace(Object message,
                        Throwable t)
Specified by:
trace in interface Logger
Overrides:
trace in class Logger

service

public final void service(Object message)
A new logging method that takes the SERVICE priority.

Specified by:
service in interface Logger

service

public final void service(Object message,
                          Throwable t)
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 (or debug or trace) would do something.

Specified by:
isServiceEnabled in interface Logger

isTraceEnabled

public final boolean isTraceEnabled()
Description copied from interface: Logger
Returns true if for this category (Logger), a call to trace would do something.

Specified by:
isTraceEnabled in interface Logger
Overrides:
isTraceEnabled in class Logger

isEnabledFor

public final boolean isEnabledFor(Level l)
Specified by:
isEnabledFor in interface Logger

shutdown

public static void shutdown()


MMBase 2.0-SNAPSHOT - null