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
org.apache.commons.logging.simplelog.log.foo=fatal
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
).
To disable this behavior, you must add a logback configuration file called logback. xml in your java classpath root. You can download this minimal logback. xml file and add it in the src/main/resources directory for a maven project or beside fr directory for a simple java project.
You can control the internal logging Log4j2 prints to the console with the status attribute at the top of the configuration file. I would recommend that you switch off the verbose debug -level logging but keep the warn and error level logging so you get informed when something goes wrong.
In Log4j you can specify a logging level for specified package, class or logger identified by string. You just simply write this in log4j.properties file:
log4j.logger.<your package> = DEBUG|INFO|OFF|WARN...
You should use:
log4j.logger.foo = 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With