开发者

log4j - set different loglevel for different packages/classes

开发者 https://www.devze.com 2023-02-01 06:22 出处:网络
I use log4j for logging and i want to print all logger.debug statements in a particular class / selected package.

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 ?


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


Copying from my current log4j.properties:

log4j.logger.org.hibernate.tool.hbm2ddl=warn
log4j.logger.org.hibernate.sql=info
0

精彩评论

暂无评论...
验证码 换一张
取 消