org.objectweb.util.monolog

Class 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

Author:
S.Chassande-Barrioz

Field Summary

static String
DEFAULT_MONOLOG_FILE
is the default monolog configuration file lookup from the file system or from the classpath.
static String
JDK_WRAPPER_CLASS_NAME
is the class name of logger factory for the java.util.logging logging system.
static String
LOG4JMini_WRAPPER_CLASS_NAME
is the class name of logger factory for the log4jME logging system.
static String
LOG4J_WRAPPER_CLASS_NAME
is the class name of logger factory for the log4j logging system.
static String
MONOLOG_CLASS_NAME
is the property name of the wrapper class name.
static String
MONOLOG_FILE_NAME
is the property name of the monolog configuration file.
static boolean
debug
Inidicates if the monolog wrapper must be logged itself.
static LoggerFactory
loggerFactory
Deprecated. use monologFactory
static MonologFactory
monologFactory
is the last required logger factory.

Method Summary

static void
debug(String m)
This method must be only used to debug the Monolog wrappers.
static MonologFactory
getDefaultMonologFactory()
static HandlerFactory
getHandlerFactory(String className)
static LevelFactory
getLevelFactory(String className)
static LoggerFactory
getLoggerFactory(String className)
static MonologFactory
getMonologFactory()
static MonologFactory
getMonologFactory(Properties properties)
Initializes monolog in with a Properties instance.
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.
static LoggerFactory
init()
Deprecated. use initialize()
static LoggerFactory
init(Properties properties)
Deprecated. use getMonologFactory(Properties)
static LoggerFactory
init(String fileName)
Deprecated. use getMonologFactory(String)
static MonologFactory
initialize()
Initializes Monolog.
static MonologFactory
instanciateMonologFactory(String className)
Retrieves a MonologFactory instance.
static void
loadMonologConfiguration(Properties properties)
Loads a monolog configuration into the loggerFactory.
static void
loadMonologConfiguration(Properties properties, LoggerFactory lf)
Deprecated. use loadMonologConfiguration(Properties, MonologFactory)
static void
loadMonologConfiguration(Properties properties, MonologFactory mf)
Loads a monolog configuration into an existing MonologFactory.

Field Details

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

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

Method Details

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

Parameters:
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()


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.

Parameters:
properties - can contains the MONOLOG_CLASS_NAME property and the rest of the monolog configuration (loggers, handlers, levels).

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

Parameters:
fileName - is the file name of a properties reachable from the file system or the classpath.

Returns:
the loggerFactory (never null)


init

public static LoggerFactory init()

Deprecated. use initialize()


init

public static LoggerFactory init(Properties properties)

Deprecated. use getMonologFactory(Properties)


init

public static LoggerFactory init(String fileName)

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

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

Parameters:
className - is the class name of a LoggerFactory implementation. It can be a null value.

Returns:
a LoggerFactory instance (never null).


loadMonologConfiguration

public static void loadMonologConfiguration(Properties properties)
Loads a monolog configuration into the loggerFactory.

Parameters:
properties - contains the properties to load into the given logger factory.


loadMonologConfiguration

public static void loadMonologConfiguration(Properties properties,
                                            LoggerFactory lf)

Deprecated. use loadMonologConfiguration(Properties, MonologFactory)


loadMonologConfiguration

public static void loadMonologConfiguration(Properties properties,
                                            MonologFactory mf)
Loads a monolog configuration into an existing MonologFactory.

Parameters:
properties - contains the properties to load into the given logger factory.
mf - is the MonologFactory to configure.