Skip to content

log4j2.disableJmx and/or log4j2.disable.jmx seem not to work #2774

Closed
@autumoswitzerland

Description

@autumoswitzerland

Description

System property switches "log4j2.disableJmx" and/or "log4j2.disable.jmx" seem not to work!

Configuration

Version: 2.23.1 with slf4j 1.7.36

Operating system: Linux Mint 21.2 Cinnamon

JDK: Azu Zulu Build of OpenJDK - Zulu17.52+17-CA 17.0.12+7-LTS, Java version 17.0.12

Logs

2024-07-27T21:19:27.967946158Z main ERROR Could not reconfigure JMX java.lang.NoClassDefFoundError: javax/management/InstanceNotFoundException
	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:642)
	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:713)
	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:735)
	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:260)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:154)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:46)
	at org.apache.logging.log4j.LogManager.getContext(LogManager.java:197)
	at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:136)
	at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:58)
	at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
	at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:32)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:363)
	at ch.autumo.ifacex.studio.IfaceXStudio.<clinit>(IfaceXStudio.java:77)
	at ch.autumo.ifacex.studio.Main.main(Main.java:26)
Caused by: java.lang.ClassNotFoundException: javax.management.InstanceNotFoundException
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	... 14 more

2024-07-27T21:19:28.390794174Z main ERROR Could not reconfigure JMX java.lang.NoClassDefFoundError: javax/management/InstanceNotFoundException
	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:642)
	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:739)
	at org.apache.logging.log4j.core.config.Configurator.reconfigure(Configurator.java:263)
	at ch.autumo.commons.logging.Log4j2Logging.initializeInMemory(Log4j2Logging.java:184)
	at ch.autumo.commons.logging.Log4j2Logging.initializeInMemoryFile(Log4j2Logging.java:87)
	at ch.autumo.ifacex.studio.IfaceXStudio.main(IfaceXStudio.java:797)
	at ch.autumo.ifacex.studio.Main.main(Main.java:26)
Caused by: java.lang.ClassNotFoundException: javax.management.InstanceNotFoundException
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	... 7 more

Java-Code:

    public static void main(String[] args) {
        System.setProperty("log4j2.disable.jmx", "true");
        System.setProperty("log4j2.disableJmx", "true");
        ...

Later:

org.apache.logging.log4j.core.config.Configurator.reconfigure(builder.build());

Reproduction

It's a linux jpackaged executable. Those JMX bean class-not-found-exceptions are only triggered on linux, the same code on Windows and mac doesn't even seem to miss any JMX code. The log4j2-JMX disable switches seem to have no effect. I wonder if they are even filled into the log4j component properties ?!

Metadata

Metadata

Assignees

Labels

bugIncorrect, unexpected, or unintended behavior of existing code

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions