'Log4j log level for a specific message
A 3rd party library that I am importing is ouputting a DEBUG level log message that I would like log.
Normally, I only log INFO messages.
If I set my log4j2.xml to "debug" for this specific package, then I get extremely noisy logging.
Is there a way in which I can setup my log4j xml logger to output only this specific method's log message? (I cannot change this library's code, only the configuration)
<Loggers>
<Root level="INFO">
<AppenderRef ref="APPLICATION"/>
</Root>
<Logger
name="com.some.library.i.cannot.change" level="debug">
CAN I ADD SOMETHING HERE THAT WILL ONLY LOG 1 METHOD'S specific message?
<AppenderRef ref="APPLICATION"/>
</Logger>
</Loggers>
Code from the library looks something like this
void oneMethodInLibrary(){
// I want to log this message
LOG.debug("Loaded Configuration {}", config);
}
void otherMethodInLibrary(){
LOG.debug("Other noisy debug message I don't need {}", data);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
