org.mmbase.util.logging
Interface Logger

All Known Implementing Classes:
SimpleImpl, Log4jImpl

public interface Logger

The `Logger' interface for MMBase. It was designed for use with Log4j, but it is of course easy to implement it differently as well.

Implementations should also supply a getLoggerInstance static method, and can supply a configure static method.

For example:
 
 import org.mmbase.util.logging.Logging;
 import org.mmbase.util.logging.Logger;

 public class Foo {
     static Logger log = Logging.getLoggerInstance(Foo.class.getName()); 
     public void bar() {
         ...
         log.info("Hello world!");
         ...
         if(log.isDebugEnabled()) {
             log.debug("Oops, that's not quite right!");
         }
         ...
     }
 }
 
 

Author:
Michiel Meeuwissen

Method Summary
 void debug(java.lang.Object m)
          Logs the message m with debug priority.
 void error(java.lang.Object m)
          Logs the message m with error priority.
 void fatal(java.lang.Object m)
          Logs the message m with fatal priority.
 void info(java.lang.Object m)
          Logs the message m with info priority.
 boolean isDebugEnabled()
          Returns true if for this category (Logger), a call to debug (or trace) would do something.
 boolean isServiceEnabled()
          Returns true if for this category (Logger), a call to service (debug or trace) would do something.
 void service(java.lang.Object m)
          Logs the message m with service priority.
 void setPriority(Level p)
          If you want to override the priority in the configuration file fixed for this category, you can do it with this method.
 void trace(java.lang.Object m)
          Logs the message m with trace priority.
 void warn(java.lang.Object m)
          Logs the message m with warn priority.
 

Method Detail

trace

public void trace(java.lang.Object m)
Logs the message m with trace priority. For detailled debugging.
See Also:
debug(java.lang.Object)

debug

public void debug(java.lang.Object m)
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.

service

public void service(java.lang.Object m)
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.

info

public void info(java.lang.Object m)
Logs the message m with info priority. As `service', but focussed on things system administrators are ussually most interesed in, like authorisation issues. For example changes on the database could be logged, such that one can see in the logs what happened.

warn

public void warn(java.lang.Object m)
Logs the message m with warn priority. Something strange happened, but it is not necessarily an error.

error

public void error(java.lang.Object m)
Logs the message m with error priority. Something is definitely wrong. An inconsistency was detected. It might be unpredictable what will happen.

fatal

public void fatal(java.lang.Object m)
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.

isDebugEnabled

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

isServiceEnabled

public boolean isServiceEnabled()
Returns true if for this category (Logger), a call to service (debug or trace) would do something.

setPriority

public void setPriority(Level p)
If you want to override the priority 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.
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.


MMBase 2001