Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Loggers

A logger is a source of messages. A program that is to write log information obtains logger objects from Log4j and outputs its messages via these objects.

Name space

The logger name space has a hierarchical structure. The naming convention is the same as that for Java packages. In other words, the individual levels of the hierarchy are separated from each other by dots in the name. Within this hierarchy, loggers inherit their properties from their parent loggers unless they have explicitly defined their own properties. The root of the hierarchy is formed by the “root logger”, which does not have its own name but is always present.

Example 21 Logger name space

The logger called BeanConnect is the (direct) parent logger of the logger called BeanConnect.info and is also the parent logger of the logger BeanConnect.Datasources.OLTP.

Level

The level is a property that can be assigned to both a logger and a message. When the logger is called, the logging program decides which level a message has. Depending on which level has been assigned to the relevant logger, Log4j decides whether or not the transferred message is to be logged. Messages are logged if the message level is greater than or equal to the logger level. The logger is disabled if the level is OFF.

Log4j supports the following levels (in descending order):

Level

Meaning

FATAL

Serious error, highest level

ERROR

Error

WARN

Warning

INFO

Information

DEBUG

Debug output

TRACE

Trace output, lowest level

OFF

Can only be assigned to loggers. All messages output via this logger are suppressed. The logger is switched off.

Example 22 Logging level

If a logging event with the level DEBUG is passed to a logger assigned to the level INFO, this message is suppressed, but INFO, WARN, ERROR and FATAL messages are still output.

If you set the logger level ERROR, only messages with the level ERROR and FATAL are output.