Each Jonathan implementation package has a
LoggerProvider
class, which provides the other classes
of the same package with static loggers :
There are two ways to instrument Jonathan source code :
if ((LoggerProvider.bind_logger != null) && LoggerProvider.bind_logger.isLoggable(BasicLevel.DEBUG))) { LoggerProvider.bind_logger.log(BasicLevel.DEBUG,"my message"); }
if ((LoggerProvider.export_logger != null) && (LoggerProvider.export_logger.isLoggable(BasicLevel.ERROR))) { LoggerProvider.export_logger.log(BasicLevel.ERROR,"my message", my_exception); }
The default configuration is established thanks to the Kilim configuration files (kcf files). In the runtime kcf (monolog.kcf), package loggers are mapped to the default topical logger hierarchy.
The default mapping is following :
org.objectweb.jonathan.binding.export
is default
logger for all of export loggers;org.objectweb.jonathan.binding.bind
is default
logger for all of bind loggers;org.objectweb.jonathan.communication.receive
is
default logger for all of receive loggers;The org.objectweb.jonathan.communication.send
is
default logger for all of send loggers;org.objectweb.jonathan.binding
is default logger
for the generic loggers of the org.objectweb.jonathan.binding
package and its
sub-packages;org.objectweb.jonathan.communication
is default logger
for the generic loggers of the org.objectweb.jonathan.communication
package and its
sub-packages;org.objectweb.jonathan
is default logger for the
other generic loggers.In the configuration /loggers
, a topical logger is
defined by his name (his initial topic), his associated level and a
set of handlers. These parameters may be modified by users.
However, modifying a logger name, adding a new logger or deleting a
logger will change the logger hierarchy.
[loggers] [root] ... [org] ... [objectweb] ... [jonathan] => {/factories/monolog factory,.} name => (String.class, jonathan) parent => /loggers/root/org/objectweb level => /levels/WARN additivity => (boolean, false) [handlers] 0 -> /handlers/file [binding] ... [export] ... [bind] ... [communication] ... [send] ... [receive] ...
The loggers of a package are mapped to the logger hierarchy in
the configuration /packages
. Users may modify the mapping of
the loggers used in a package. The following example describes the
mapping of the loggers of the package
org.objectweb.jonathan.protocols.tcpip
:
[packages] ... [tcpip] generic logger -> /loggers/root/org/objectweb/jonathan/communication bind logger -> /loggers/root/org/objectweb/jonathan/binding/bind export logger -> /loggers/root/org/objectweb/jonathan/binding/export send logger -> /loggers/root/org/objectweb/jonathan/communication/send receive logger -> /loggers/root/org/objectweb/jonathan/communication/receive ...
There are three default handlers defined in the configuration
/handlers
: file handler, rolling file handler and console handler. In the
following example, it is possible to specify a new pattern on the
file handler or to change the log file name.
[handlers] [file] => {/factories/monolog factory,.} name => (String.class, FileHandler) output => (String.class, jonathan_logs.txt) pattern => (String.class, %l - %O.%M : %m%n) type => (String.class, File) [file] => {/factories/monolog factory,.} name => (String.class, RollingFileHandler) output => (String.class, jonathan_logs.txt) pattern => (String.class, %l - %O.%M : %m%n) type => (String.class, RollingFile) [console] => {/factories/monolog factory,.} name => (String.class, ConsoleHandler) output => (String.class, System.err) pattern => (String.class, %l - %m%n) type => (String.class, Console)
In accordance with the Monolog specification, it is possible to use a property file for a specific configuration. User properties in the monolog.properties file will overwrite the default parameters defined in the runtime kcf.
However, users can not modify the default logger hierarchy and mapping by editing the property file.
# file monolog.properties # Logger factory class name log.config.classname org.objectweb.util.monolog.wrapper.log4j.MonologLoggerFactory ######################## # Logger configuration # ######################## #logger.org.objectweb.jonathan.level WARN #logger.org.objectweb.jonathan.additivity false #logger.org.objectweb.jonathan.handler.0 FileHandler #logger.org.objectweb.jonathan.binding.level WARN #logger.org.objectweb.jonathan.binding.additivity false #logger.org.objectweb.jonathan.binding.handler.0 FileHandler #logger.org.objectweb.jonathan.binding.export.level WARN #logger.org.objectweb.jonathan.binding.export.additivity false #logger.org.objectweb.jonathan.binding.export.handler.0 FileHandler #logger.org.objectweb.jonathan.binding.bind.level WARN #logger.org.objectweb.jonathan.binding.bind.additivity false #logger.org.objectweb.jonathan.binding.bind.handler.0 FileHandler #logger.org.objectweb.jonathan.communication.level WARN #logger.org.objectweb.jonathan.communication.additivity false #logger.org.objectweb.jonathan.communication.handler.0 FileHandler #logger.org.objectweb.jonathan.communication.send.level WARN #logger.org.objectweb.jonathan.communication.send.additivity false #logger.org.objectweb.jonathan.communication.send.handler.0 FileHandler #logger.org.objectweb.jonathan.communication.receive.level WARN #logger.org.objectweb.jonathan.communication.receive.additivity false #logger.org.objectweb.jonathan.communication.receive.handler.0 FileHandler