Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
/ Log4j-StaticShutdown Public archive

Provide a ShutdownRegistrationStrategy for Log4j 2 designed to be manually invoked.

License

Notifications You must be signed in to change notification settings

DjDCH/Log4j-StaticShutdown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Log4j-StaticShutdown

Travis Maven Central MIT License

Provide a ShutdownRegistrationStrategy for Log4j 2 designed to be manually invoked.

Requirements

  • Java and Maven installed

Build your project

Add the dependency in your pom.xml file:

<dependency>
    <groupId>com.djdch.log4j</groupId>
    <artifactId>log4j-staticshutdown</artifactId>
    <version>1.1.0</version>
</dependency>

Add this static initialization block in your Main class:

static {
    System.setProperty("log4j.shutdownCallbackRegistry", "com.djdch.log4j.StaticShutdownCallbackRegistry");
}

WARNING! Even if this works, there is no warranty that it always will, since there is no way to ensure that your Main class will be loaded before Log4j (and it won't work if that doesn't happen). To be safe, you should instead set the system property from the command line when launching your jar.

Then, you can invoke manually the StaticShutdownCallbackRegistry in your shutdown procedure:

StaticShutdownCallbackRegistry.invoke();

About

Provide a ShutdownRegistrationStrategy for Log4j 2 designed to be manually invoked.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages