Skip to content
Advertisement

log4j custom appender stop method not getting called

I am trying to implement a custom log appender for log4j and will need to initialize some resources before start and cleanup at the end. Somehow my stop method will not be executed. I’ve tried using LogManager.shutdown(); but I cannot see my method getting called.

This is my appender class:

JavaScript

And this is a simple test

JavaScript

I can see the console output

JavaScript

but I am missing the output from my stop method:

JavaScript

Advertisement

Answer

Got the solution, I had to use/override the stop method like this

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement