Java – why does log4j completely record everything in debug?

So I have a problem. When I switch the root logger to debug, log4j seems to want to record everything that can be "debugged"

This is my file:

log4j.rootLogger=DEBUG,READER
log4j.appender.READER=org.apache.log4j.ConsoleAppender

log4j.appender.READER.layout=org.apache.log4j.PatternLayout

log4j.appender.READER.layout.ConversionPattern=[%-5p] %t->%c{1} - %m%n

com.myclass.readers=DEBUG,READER

Now all I want is the debug statement I want to define under the printed reader class The problem I encountered was that the Apache HTTP package I used in my reader class also seemed to start dumping its debugging content

How can I limit this to the content in the class? I read it on the Internet. I'm not sure if I just missed something completely, but I can't seem to solve the problem

thank you!

Solution

It appears that you have set rootlogger to debug level:

log4j.rootLogger=DEBUG

If not specified separately, all loggers will inherit the rootlogger level

Therefore, set the level of rootlogger to error or warn, and then only com myclass. Readers is at debug level

log4j.rootLogger=ERROR,READER
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>