I want to use the log4j2 JUL adapter in an OSGi environment. So I directly used log4j2 OSGi bundles and set the following system property in one of my custom OSGi bundle as mentioned here:
System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager");
It seems like this system property is not setting because logs coming from Java util framework is not going to appenders.
The OSGi framework that I'm using is Eclipse Equinox.
Where could I set this system property to work with OSGi?
EDIT:
As far as I understood here the problem is at the very begging of the JVM start the required property i.e. java.util.logging.manager
is set to its default value, so setting this inside the OSGi environment is not effective, even we cannot set this property using -D
option because the log4j2 OSGi bundles are not exposed to the class path, so that class not found exception occurs.
Any help is highly appreciate on this matter.
Generally, if setting a property through the
System.setProperty
API does not work OK (maybe because the property has already been read before you can even overwrite it), you should try setting it from the very JVM start, entering "-D" arguments at the command line: