Log4j JDK Logging Adapter

The JDK Logging Adapter is a custom implementation of java.util.logging.LogManager that uses Log4j. This adapter can be used with either the Log4j API or Log4j Core. When used with the API, there are a couple features of JUL that aren’t supported. However, this does allow any other Log4j Provider besides the Core provider to be used with JUL.

Requirements

The JDK Logging Adapter is dependent on the Log4j API and optionally Log4j Core. For more information, see Runtime Dependencies.

Usage

To use the JDK Logging Adapter, you must set the system property java.util.logging.manager to org.apache.logging.log4j.jul.LogManager

This must be done either through the command line (i.e., using the -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager argument) or by using System.setProperty() before any calls are made to LogManager or Logger.

Compatibility

The use of a java.util.logging.Filter is supported on a per-Logger basis. However, it is recommended to use the standard Filters feature in Log4j instead.

The use of java.util.logging.Handler classes is NOT supported. Custom Handlers should instead use an appropriate Appender or code their own Appender plugin.

Java logging levels are translated into Log4j logging levels dynamically. The following table lists the conversions between a Java logging level and its equivalent Log4j level. Custom levels should be implemented as an implementation of LevelConverter, and the Log4j property log4j.jul.levelConverter must be set to your custom class name. Using the default LevelConverter implementation, custom logging levels are mapped to whatever the current level of the Logger being logged to is using.

Default Level Conversions

Java LevelLog4j Level
OFFOFF
SEVEREERROR
WARNINGWARN
INFOINFO
CONFIGCONFIG
FINEDEBUG
FINERTRACE
FINESTFINEST
ALLALL