Configure Log4j To Disable Specific Package (Java)

I came across the need to disable logging (debug) for a specific package in Apache Log4j today whilst coding. It’s simple. All you need to do is precede the package name, e.g. net.beplacid, with log4j.logger and follow that with “=LEVEL”, where ‘level’ is one of TRACE, DEBUG, INFO, WARN, ERROR and FATAL – the standard Log4j logging levels. To demonstrate:

log4j.logger.net.beplacid=DEBUG

Would set the logging level to DEBUG for all registered loggers in classes net.beplacid. Similarly:

log4j.logger.net.beplacid=FATAL

Would disable all but FATAL logging calls.

Hope that helps someone, I couldn’t find an ‘easy fix’ page when searching…

3 Comments

  1. Rajesh
    Posted May 21, 2009 at 21:47 | Permalink

    thanks .. it seems to help me … :)
    - Raj

  2. pepe
    Posted July 20, 2010 at 07:53 | Permalink

    it help me alot…

  3. chaitanya
    Posted August 22, 2010 at 18:09 | Permalink

    Thanks.

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*