File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes Log4j Levels/Layer Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Log4j Levels/Layer Query" Watch "Log4j Levels/Layer Query" New topic

Log4j Levels/Layer Query

Vaibhav G Garg
Ranch Hand

Joined: Sep 23, 2011
Posts: 141
We are using the log4j for logging purpose in our web application project. Currently, we are using the same level of logging (debug, info etc.) across all the layers. But, now we would like to enable the different levels of logging at different layers (in the same log file). Please suggest if this is possible or not. And if yes, then what is the approach?
Vaibhav G Garg
Ranch Hand

Joined: Sep 23, 2011
Posts: 141
Please provide your inputs on this if anyone has any idea about this configuration.
Joe Ess

Joined: Oct 29, 2001
Posts: 9188

When you create a Logger or Category instance, you give it a String name. You can change Log4j's configuration to throttle the output from a particular name, or an entire branch of a hierarchy (Log4j names can use dot notation like Java package names). The common practice is to use the class name as the name for the Logger, then you can pick individual classes or packages to get more/less information on in your configuration.
The documentation has some examples.

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: Log4j Levels/Layer Query
It's not a secret anymore!