Using JBoss LogManager (1.1.x) in a standalone program
JBoss LogManager 1.1.x is a replacement for the JDK 1.4 logging system LogManager that fixes or works around many serious problems in the default implementation. Since many frameworks and libraries (as well as the JDK itself) use this logging facility, having robust support for it is an essential requirement for many applications.
To use it outside of JBossAS, follow these steps.
1. Get the following resources via Maven (these all may be found in the JBoss Maven repository at http://repository.jboss.org/maven2):
Group ID | Artifact ID(s) | Required? |
---|---|---|
org.jboss.logmanager | jboss-logmanager (1.1.x or later) | Yes |
org.jboss.logmanager | jboss-logmanager-log4j | No (unless you require support for bridging from log4j) (you will also need the log4j JAR) |
org.jboss.slf4j | slf4j-jboss-logmanager | No (unless you require support for bridging from slf4j or Apache commons-logging) (you will also need the slf4j API JAR) |
org.jboss.logging | jboss-logging-spi jboss-logging-logmanager (both 2.2.x or later) | No (unless you require support for bridging from jboss-logging) |
org.jboss.logbridge | jboss-logbridge | No (unless you require support for bridging to log4j) |
2. Specify the alternate log manager as a system property, either on the command-line or as a part of your early boot process:
-Djava.util.logging.manager=org.jboss.logmanager.LogManager
3. Specify your logging configuration properties (see JBossBootLogging for information about how to set up this properties file).
4. If you require bridging support from log4j to JBoss LogManager, follow these two steps:
4.1. Specify the special system property to disable automatic log4j configuration:
-Dlog4j.defaultInitOverride=true
4.2. In your early boot process, install the special repository selector:
static { new org.jboss.logmanager.log4j.BridgeRepositorySelector().start(); }
5. If you require bridging support from JBoss Logging to JBoss LogManager, be sure to specify the appropriate system property:
-Dorg.jboss.logging.Logger.pluginClass=org.jboss.logging.logmanager.LoggerPluginImpl
6. If you require bridging support from SLF4J to JBoss LogManager, simply place the slf4j-jboss-logmanager JAR in your classpath and SLF4J will automatically log to JBoss LogManager.
7. If you require bridging support from Apache/Jakarta Commons Logging, use the jcl-over-slf4j library provided by the SLF4J project.
8. If you require bridging support from JBoss LogManager to Log4j, the deprecated jboss-logbridge project is available but you're on your own.
Comments