I am using org.apache.log4j.Logger for logging and I am developing a jsp just for monitoring purposes. This jsp is using classes that write logs (INFO level) not interesting for this monitoring, but annoying, as long as I want to execute this jsp very often.
So, my question is the next: Is there any way to disable these INFO logs just for the thread where my jsp is running?
If there is not, maybe this approach might pay the bill: Is there any way to tell log4j level for one given class is FATA开发者_高级运维L just for a few milliseconds?
There's no easy way to do this using simple log4j config.
However, you can have your code install a custom filter on the appropriate logger. See the interface reference here:
http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/spi/Filter.html
- Construct an object that implements the filter you want.
- Find the logger using LogManager.getLogger("loggername")
- Insert the filter.
Is the thread-id being logged? If so, can't you just use grep -v to remove the annoying lines that are for that thread and INFO level?
精彩评论