org.mmbase.util.logging.java
Class Impl

java.lang.Object
  extended by org.mmbase.util.logging.java.Impl
All Implemented Interfaces:
Logger

public final class Impl
extends Object
implements Logger

Since java 1.4 there is a Logger implemented in java itself; this MMBase Logger implementation delegates all logging to this java framework. The java framework is comparable to log4j, so you could use it as an alternative.

Level in MMBase's LevelLevel in Java's Level
TRACELevel.FINEST
TRACELevel.FINER
DEBUGLevel.FINE
SERVICELevel.CONFIG
INFOLevel.INFO
WARNLevel.WARNING
ERRORLevel.SEVERE
FATALLevel.SEVERE

Since:
MMBase-1.8
Author:
Michiel Meeuwissen
See Also:
MMBaseLogger

Constructor Summary
protected Impl(String name)
          Constructor.
 
Method Summary
static void configure(String s)
          Calls LogManager#readConfiguration, and feeds it with the configured InputStream.
 void debug(Object m)
          Logs the message m with debug priority.
 void debug(Object m, Throwable t)
           
 void error(Object m)
          Logs the message m with error priority.
 void error(Object m, Throwable t)
           
 void fatal(Object m)
          Logs the message m with fatal priority.
 void fatal(Object m, Throwable t)
           
protected  Level getJavaLevel(Level p)
           
static Impl getLoggerInstance(String name)
          Return a MMBase logger object, which wrappes a java.util.logging.Logger object.
 void info(Object m)
          Logs the message m with info priority.
 void info(Object m, Throwable t)
           
 boolean isDebugEnabled()
          Returns true if for this category (Logger), a call to debug (or trace) would do something.
 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 m)
          Logs the message m with service priority.
 void service(Object m, 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.
 void trace(Object m)
          Logs the message m with trace priority.
 void trace(Object m, Throwable t)
           
 void warn(Object m)
          Logs the message m with warn priority.
 void warn(Object m, Throwable t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Impl

protected Impl(String name)
Constructor. This calls java's Logger.getLogger(String).

Method Detail

getLoggerInstance

public static Impl getLoggerInstance(String name)
Return a MMBase logger object, which wrappes a java.util.logging.Logger object.


configure

public static void configure(String s)
Calls LogManager#readConfiguration, and feeds it with the configured InputStream. So you can configure java-logging. The file is watched, so you can add and change it later. There need not be a configuration file for java logging.


getJavaLevel

protected Level getJavaLevel(Level p)

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.

trace

public void trace(Object m)
Description copied from interface: Logger
Logs the message m with trace priority. For detailled debugging.

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

trace

public void trace(Object m,
                  Throwable t)
Specified by:
trace in interface Logger

debug

public void debug(Object m)
Description copied from interface: Logger
Logs the message m with debug priority. Everything a non-developer never wants to see, but you do, to * keep track of what is happening. There can be a lot of them in the code, so it is important that you well protect them with `isDebugEnabled's, to minimize overhead.

Specified by:
debug in interface Logger

debug

public void debug(Object m,
                  Throwable t)
Specified by:
debug in interface Logger

service

public void service(Object m)
Description copied from interface: Logger
Logs the message m with service priority. An interested system administrator might want to see these things. For examples all queries to the database could be logged with `service' priority. Or if a image is calculated, that could be logged as a `service'. One would get a fairly good idea what MMBase is doing if `service' is switched on.

Specified by:
service in interface Logger

service

public void service(Object m,
                    Throwable t)
Specified by:
service in interface Logger

info

public void info(Object m)
Description copied from interface: Logger
Logs the message m with info priority. As `service', but focussed on things system administrators are usually most interested in, like authorisation issues. For example changes on the database could be logged, such that one can see in the logs what happened.

Specified by:
info in interface Logger

info

public void info(Object m,
                 Throwable t)
Specified by:
info in interface Logger

warn

public void warn(Object m)
Description copied from interface: Logger
Logs the message m with warn priority. Something strange happened, but it is not necessarily an error.

Specified by:
warn in interface Logger

warn

public void warn(Object m,
                 Throwable t)
Specified by:
warn in interface Logger

error

public void error(Object m)
Description copied from interface: Logger
Logs the message m with error priority. Something is definitely wrong. An inconsistency was detected. It might be unpredictable what will happen.

Specified by:
error in interface Logger

error

public void error(Object m,
                  Throwable t)
Specified by:
error in interface Logger

fatal

public void fatal(Object m)
Description copied from interface: Logger
Logs the message m with fatal priority. The progam could not function any more. Normally, you would throw an exception, which then will be logged with fatal priority. I've made an arangement in `Logger' that logs uncatched exceptions with fatal priority, but nevertheless it's better to always catch all exceptions in a more regulated way.

Specified by:
fatal in interface Logger

fatal

public void fatal(Object m,
                  Throwable t)
Specified by:
fatal in interface Logger

isTraceEnabled

public 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

isDebugEnabled

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

Specified by:
isDebugEnabled in interface Logger

isServiceEnabled

public 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

isEnabledFor

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


MMBase 2.0-SNAPSHOT - null