How to disable loggers of a class or of whole package?

JavaApache Commons-Logging

Java Problem Overview

I am using Apache Commons Logging ™. For now I wanted to use SimpleLog implementation, but when I changed the level, loggers from the libraries came out. I want it to turn them off.

Is there a easy way to change log level for whole package (can Log4j do that)?

I have tried to set


in the property files to disable (setting to fatal is OK) foo logger, but it doesn't work (foo is a name of logger that appears in output : [INFO] foo - Message).

Java Solutions

Solution 1 - Java

In Log4j you can specify a logging level for specified package, class or logger identified by string. You just simply write this in file:

log4j.logger.<your package> = DEBUG|INFO|OFF|WARN...

Solution 2 - Java

You should use: = OFF

Please note that "foo" does not need to be a package, or a class, but is an arbitrary String. We e.g. have a logger named "SQL" that is called from many classes.

Solution 3 - Java

If you use Spring Boot, you may set to OFF in file, by using logging.level.<package-or-class-name>=OFF Example:


Solution 4 - Java

Use of SimpleLog from Commons Logging requires two configuration files unless you are using some system properties. The files are: and The log level properties you have indicated should be placed in like:

where "foo" is the logger name. Generally, this is the package or package and class name. In the following example, everything under the com.stackoverflow.utils package is set to info whereas com.stackoverflow.servlet.Dispatcher is specifically set to warn: 

The file should contain:


Documentation here and here.


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDamianView Question on Stackoverflow
Solution 1 - JavaArekView Answer on Stackoverflow
Solution 2 - JavaDanielView Answer on Stackoverflow
Solution 3 - JavaLee Chee KiamView Answer on Stackoverflow
Solution 4 - Javajt.View Answer on Stackoverflow