org.objectweb.util.monolog
Class Monolog
java.lang.Object
org.objectweb.util.monolog.Monolog
public class Monolog
extends java.lang.Object
This class is a helper to instanciate a logger factory. It provides a set of
init(...) method with various parameter:
- no parameter => automatic configuration with system property and default
values
- Properties => contains monolog configuration (loggers, handlers, levels
and optionaly the wrapper class name (automatic choice if not specified)).
- String => the class name of the wrapper class to instanciate
- S.Chassande-Barrioz
DEFAULT_MONOLOG_FILE
public static final String DEFAULT_MONOLOG_FILE
is the default monolog configuration file lookup from the file system or
from the classpath.
JDK_WRAPPER_CLASS_NAME
public static final String JDK_WRAPPER_CLASS_NAME
is the class name of logger factory for the java.util.logging logging
system.
LOG4JMini_WRAPPER_CLASS_NAME
public static final String LOG4JMini_WRAPPER_CLASS_NAME
is the class name of logger factory for the log4jME logging system.
LOG4J_WRAPPER_CLASS_NAME
public static final String LOG4J_WRAPPER_CLASS_NAME
is the class name of logger factory for the log4j logging system.
MONOLOG_CLASS_NAME
public static final String MONOLOG_CLASS_NAME
is the property name of the wrapper class name. This property is searched
from the specified properties or from the system properties.
MONOLOG_FILE_NAME
public static final String MONOLOG_FILE_NAME
is the property name of the monolog configuration file. This property
is searched from the specified properties or from the system properties.
debug
public static boolean debug
Inidicates if the monolog wrapper must be logged itself.
loggerFactory
public static LoggerFactory loggerFactory
use monologFactory
monologFactory
public static MonologFactory monologFactory
is the last required logger factory. By default it is initialized to the
a basic logger factory implementation (LoggerImpl).
debug
public static void debug(String m)
This method must be only used to debug the Monolog wrappers.
To active the log of monolog assign the "true" value to the system
property "monolog.debug".
m
- the message to log.
getDefaultMonologFactory
public static MonologFactory getDefaultMonologFactory()
getHandlerFactory
public static HandlerFactory getHandlerFactory(String className)
getLevelFactory
public static LevelFactory getLevelFactory(String className)
getLoggerFactory
public static LoggerFactory getLoggerFactory(String className)
getMonologFactory
public static MonologFactory getMonologFactory(Properties properties)
Initializes monolog in with a Properties instance.
It searches from the properties the logger factory class name (
MONOLOG_CLASS_NAME property) and it delegates its configuration to
the loadMonologConfiguration(Properties, LoggerFactory) method.
properties
- can contains the MONOLOG_CLASS_NAME property and the
rest of the monolog configuration (loggers, handlers, levels).
- the loggerFactory (never null)
getMonologFactory
public static MonologFactory getMonologFactory(String fileName)
Initializes Monolog with a given monolog configuration file name
if the file is found, it delegates the intialization to init(Properties)
method. if the file is not found it delegates the logger factory
instanciation to the getLoggerFactory(String) method.
fileName
- is the file name of a properties reachable from the
file system or the classpath.
- the loggerFactory (never null)
init
public static LoggerFactory init(Properties properties)
use getMonologFactory(Properties)
init
public static LoggerFactory init(String fileName)
use getMonologFactory(String)
initialize
public static MonologFactory initialize()
Initializes Monolog.
It searches in system properties a monolog configuration file
(MONOLOG_FILE_NAME system property) or use the default file name
(DEFAULT_MONOLOG_FILE system property).
- the loggerFactory (never null)
instanciateMonologFactory
public static MonologFactory instanciateMonologFactory(String className)
Retrieves a MonologFactory instance.
First it tries to instanciate the given logger factory class name.
If it is not possible it tries to instanciate the logger factory of the
log4j system (if the classes are availlable).
If log4j or its wrapper are not reachable then it tries to instanciate
the wrapper of the log4jME logging system.
If log4jME or its wrapper are not reachable then it tries to instanciate
the wrapper of the java.util.logging logging system.
Finally if any of these wrappers are reachable the basic logger factory
is used.
className
- is the class name of a LoggerFactory implementation.
It can be a null value.
- a LoggerFactory instance (never null).
loadMonologConfiguration
public static void loadMonologConfiguration(Properties properties)
Loads a monolog configuration into the loggerFactory.
properties
- contains the properties to load into the given logger
factory.
loadMonologConfiguration
public static void loadMonologConfiguration(Properties properties,
LoggerFactory lf)
use loadMonologConfiguration(Properties, MonologFactory)
loadMonologConfiguration
public static void loadMonologConfiguration(Properties properties,
MonologFactory mf)
Loads a monolog configuration into an existing MonologFactory.
properties
- contains the properties to load into the given logger
factory.mf
- is the MonologFactory to configure.