logmgr-log4j2

JDK LogManager implementation for log4j 2.x

License

License

GroupId

GroupId

com.github.schnitker.logmanager
ArtifactId

ArtifactId

logmgr-log4j2
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

logmgr-log4j2
JDK LogManager implementation for log4j 2.x
Project URL

Project URL

https://github.com/Schnitker/LogManager
Project Organization

Project Organization

Rainer Schnitker
Source Code Management

Source Code Management

https://github.com/Schnitker/LogManager

Download logmgr-log4j2

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.schnitker.logmanager/logmgr-log4j2/ -->
<dependency>
    <groupId>com.github.schnitker.logmanager</groupId>
    <artifactId>logmgr-log4j2</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.schnitker.logmanager/logmgr-log4j2/
implementation 'com.github.schnitker.logmanager:logmgr-log4j2:1.0.2'
// https://jarcasting.com/artifacts/com.github.schnitker.logmanager/logmgr-log4j2/
implementation ("com.github.schnitker.logmanager:logmgr-log4j2:1.0.2")
'com.github.schnitker.logmanager:logmgr-log4j2:jar:1.0.2'
<dependency org="com.github.schnitker.logmanager" name="logmgr-log4j2" rev="1.0.2">
  <artifact name="logmgr-log4j2" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.schnitker.logmanager', module='logmgr-log4j2', version='1.0.2')
)
libraryDependencies += "com.github.schnitker.logmanager" % "logmgr-log4j2" % "1.0.2"
[com.github.schnitker.logmanager/logmgr-log4j2 "1.0.2"]

Dependencies

compile (2)

Group / Artifact Type Version
org.apache.logging.log4j : log4j-api jar 2.0.2
org.apache.logging.log4j : log4j-core jar 2.0.2

Project Modules

There are no modules declared in this project.

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'.

Versions

Version
1.0.2
1.0.1
1.0.0