Stanley Mungai
Stanley Mungai

Reputation: 4150

Log4j Log at all Classes Level

I am Debugging my Java Web Application Using Log4j, I need to Log At Class Level. I do not want to put a line for each Class in my log4j.properties file as I have hundreds of classes in my application like this:

log4j.logger.com.my.package.class1=DEBUG
log4j.logger.com.my.package.class2=DEBUG
log4j.logger.com.my.package.class3=DEBUG

Is there a one line setup to Achieve loggin for all the Classes?

Upvotes: 0

Views: 1855

Answers (2)

D3X
D3X

Reputation: 547

LOG4J is designed in a pattern of systematic hierarchical structure, by the order of its names given.

Following image depicts the hierarchical representation of loggers

  • So if you need to override or re-configure the root node logger you need the log4j.logger.com.my.package in your case, and override the specific configuration of the child loggers.

Ref Link

Upvotes: 0

user3159253
user3159253

Reputation: 17455

All loggers are ordered into a hierarchy, by its names. So you may to configure a parent logger ("log4j.logger.com.my.package" or root logger) and override configuration for some of child loggers if you need. See more at http://logging.apache.org/log4j/2.x/manual/architecture.html .

Upvotes: 4

Related Questions