简体   繁体   中英

Specify logger level in log4j2 via JMX for unregistered loggers

I use JMX client to change logger level in log4j programatically. It works fine, but how can specify logger level for non-registered (that aren't specified in log4j2.xml) loggers?

For instance I have the following loggers block:

<Loggers>
        <Root level="WARN">
            <AppenderRef ref="async"/>
        </Root>
        <Logger name="com.example" level="INFO" />
        <Logger name="com.example.java" level="INFO" />
</Loggers>

I have "com.example" and "com.example.java" loggers available for using via JMX. But what if I need specify logger level for "com.example.java.Runner" or for "com.example.groovy"?

At the moment (version 2.1) this is not possible. JMX only instruments Loggers that are in the configuration.

Without JMX, you can do something like mentioned here: Programmatically change log level in Log4j2

But this also only works for loggers that are named in the configuration...

Have you tried remotely editing the Log4j configuration as outlined in the Client GUI section here ?

Clicking the "Reconfigure with XML below" button will send the configuration text to the remote application where it will be used to reconfigure Log4j on the fly. This will not overwrite any configuration file. Reconfiguring with text from the editor happens in memory only and the text is not permanently stored anywhere.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM