Pax-log4j2 logging configuration ignored after OSGi stops

334 Views Asked by At

I have a maven project with number of OSGi bundles and I use log4j2 with pax-logging for the logging backend. When I stop the program, after the OSGi framework is shut down the rest of the logs does not follow the log4j2 configurations and so the log messages take a different pattern. I have used the following two system properties:

org.ops4j.pax.logging.DefaultServiceLog.level=WARN 
org.ops4j.pax.logging.property.file=path/to/pax-logging.properties

to set pax-logging.properties config file and for defaultSerivceLog level and log4j2.xml is the configuration file used for logging. After OSGi is shut down the pax-logging is used but not with log4j2 configurations. I want to get it logged through pax-log4j2.

1

There are 1 best solutions below

0
On

As per my answer here I think you just need to declare a property in the file org.ops4j.pax.logging.cfg:

org.ops4j.pax.logging.log4j2.config.file=path/to/log4j2.xml

to configure the Log4j2 configuration with pax-logging-log4j2 implementation.