Skip to content

JDK LogManager implementations for Log4j, Log4j2 and Logback. Alternative to SLF4JBridgeHandler.

License

Notifications You must be signed in to change notification settings

Schnitker/LogManager

Repository files navigation

LogManager

JDK LogManager implementations for Log4j, Log4j2, Logback and servlet containers.

Introduction

My favorite Framework Jersey (JAX-RS 2.0) uses JDK logging. There are some disadvantages with JDK Logging:

This project allows you to redirect JDK logging to Log4j (1.x or 2.x) or Logback without performance costs. Configuration changes are immediately noticed by the JDK logging wrapper. The JDK LogManager and Logger are completely replaced.

The Jersey Grizzly HTTP server (jersey-container-grizzly2-http) works fine with all wrapper implementations.

Usage (for applications)

  • Set system property in main method:
    System.setProperty( "java.util.logging.manager", JulLogManager.class.getName() );

  • Set system property on command line:
    java -Djava.util.logging.manager=com.github.schnitker.logmgr.log4j.JulLogManager

Servlet container

Note that the JDK LogManager does not work well with servlet containers.

There is an context class loader friendly implementation in the module 'logmgr-factory'. The factory searches through the Java ServiceLoader for an implementation of com.github.schnitker.logmgr.JulLoggerFactory. The module 'logmgr-factory' must be added to the bootstrap libraries and the system property java.util.logging.manager must be set.

Every web application instance can contain one logging wrapper.

|             Bootstrap                 | 
| (logmgr-factory) |
+------------------+--------------------+
| Webapp1 | Webapp2 |
| (logmgr-log4j) | (logmgr-logback) |
Tomcat
  • Eclipse start: Add the VM argument -Djava.util.logging.manager=com.github.schnitker.logmgr.JulLogManager and add the logmgr-factory jar file in the run/debug configuration.
  • Installation: You must extend the CLASSPATH environment variable (add logmgr-factory.jar) and set the LOGGING_MANAGER environment variable to com.github.schnitker.logmgr.JulLogManager in the catalina shell script.

Maven Repository

Current artifacts:

  • Log4j 1.x implementation:
    'com.github.schnitker.logmanager:logmgr-log4j:1.0.2'

  • Log4j 2.x implementation:
    'com.github.schnitker.logmanager:logmgr-log4j2:1.0.2'

  • Logback implementation:
    'com.github.schnitker.logmanager:logmgr-logback:1.0.2'

  • Servlet container implementation:
    'com.github.schnitker.logmanager:logmgr-factory:1.0.2'

Gradle

The project uses the gradle build system.

  • Eclipse Setup: Run the command 'gradlew eclipse' or 'gradlew cleanEclipse eclipse'.

  • Building artifacts: Call 'gradlew assemble'.

About

JDK LogManager implementations for Log4j, Log4j2 and Logback. Alternative to SLF4JBridgeHandler.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published