org.mmbase.util.logging
Class Logging

java.lang.Object
  |
  +--org.mmbase.util.logging.Logging

public class Logging
extends java.lang.Object

With this class the logging is configured and it supplies the `Logger' objects.

For example:

 
 import org.mmbase.util.logging.Logging;
 import org.mmbase.util.logging.Logger;
 import org.mmbase.util.logging.Level;

 public class test {
 
     static {
         Logging.configure("log.xml");
     }
 
     static Logger log = Logging.getLoggerInstance(test.class.getName());
   		
     public static void main(String[] args) { 		 
         log.debug("start");
         log.info("Entering application.");
	   
         log.setPriority(Level.TRACE);
         if (log.isDebugEnabled()) {
             log.debug("debug een");
             log.trace("trace twee");
         }
         log.info("info");		
         log.service("service");
 

         Logging.shutdown();
     }
 }
 
 

Author:
Michiel Meeuwissen

Method Summary
static void configure(java.lang.String configfile)
          Configure the logging system.
static void configureClass(java.lang.String configuration)
          Calls the 'configure' static method of the used logging class, or does nothing if it doesn't exist.
static java.io.File getConfigurationFile()
          Logging is configured with a log file.
static Logger getLoggerInstance(java.lang.String s)
          After configuring the logging system, you can get Logger instances to log with.
static void shutdown()
          If the configured Logger implements a shutdown static method, it will be called.
static java.lang.String stackTrace(java.lang.Throwable e)
          Returns the stacktrace of an exception as a string, which can be logged handy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

configure

public static void configure(java.lang.String configfile)
Configure the logging system.
Parameters:
configfile - Path to an xml-file in which is described which class must be used for logging, and how this will be configured (typically the name of another configuration file).

configureClass

public static void configureClass(java.lang.String configuration)
Calls the 'configure' static method of the used logging class, or does nothing if it doesn't exist. You could call this method if you want to avoid using 'configure', which parses an XML file.

getConfigurationFile

public static java.io.File getConfigurationFile()
Logging is configured with a log file. This method returns the File which was used.

getLoggerInstance

public static Logger getLoggerInstance(java.lang.String s)
After configuring the logging system, you can get Logger instances to log with.
Parameters:
s - A string describing the `category' of the Logger. This is a log4j concept.

shutdown

public static void shutdown()
If the configured Logger implements a shutdown static method, it will be called. (the log4j Category does).

stackTrace

public static java.lang.String stackTrace(java.lang.Throwable e)
Returns the stacktrace of an exception as a string, which can be logged handy. Doing simply e.printStackTrace() would dump the stack trace to standard error, which with the log4j implementation will appear in the log file too, but this is a little nicer. It is also possible to call 'error' or 'fatal' with an extra argument.
Parameters:
e - the Throwable from which the stack trace must be stringified.


MMBase 2001