Child pages
  • Logging / I18N

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • SLF4J API
  • FR I18N framework (i18n-core component)

    The I18N framework provides in the i18n-slf4j module, a LocalizedLogger class, which should be used everywhere in the code to log messages and?/or exceptions.
    The LocalizedLogger class delegates to SLF4J API.

    An SLF4J implementation can be choosed chosen at runtime by providing the appropriate jar in the classpath. In particular, two implementations are used:
  • OpenDJ implementation, used when the opendj-slf4j-adapter jar is included. It delegate to ErrorLogger and DebugLogger classes from OpenDJ server.
    • this implementation is used in the server.
  • java.util.logging implementation, used when the slf4j-jdk14 jar is included.
    • this implementation is used in the tools. 

Log levels

A message can be logged using the following levels (provided by SLF4J API and LocalizedLogger class):

...

Each logged message has a category. The category is given by the classname  where the message is logged. 

This allow allows to define a single logger per class, with the classname.

...

There is a mapping between packages (information which is included in classnames) and these simple categories. If a class does not map to a pre-defined package, then its category is its fully qualified class name. 

For example, all classes in the org.forgerock.opendj.server.core package or a sub-package are mapped to the CORE category.

...

Code Block
logger.trace("a debug message with arg1 : %s and arg2 : %s", arg1, arg2)

There is also a specific method to trace an exception in addition to the message:

Code Block
logger.traceException(anException, "a debug message with arg1 : %s and arg2 : %s", arg1, arg2)

 

 

 

...