Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log4j - set different loglevel for different packages/classes

Tags:

java

log4j

I use log4j for logging and i want to print all logger.debug statements in a particular class / selected package.

i set the cfg as below>

log4j.category.my.pkg=info log4j.category.my.pkg.ab.class1=debug 

but still only info messages are shown..

is this not the right way ?

like image 553
jch Avatar asked Dec 24 '10 16:12

jch


People also ask

What is the default logging level in log4j?

Note that by default Log4j assigns the root logger to Level. ERROR.


1 Answers

Instead of using 'category' use 'logger'. Hence, these level are configured for entire log4j, and does not depend on appender, etc.

Following change works:

log4j.logger.my.pkg=info log4j.logger.my.pkg.ab.class1=debug 
like image 104
dogbane Avatar answered Sep 23 '22 17:09

dogbane