Advertisement

07.25.2007 at 02:15PM PDT, ID: 22721312
[x]
Attachment Details

How to write log4j properties file to specify logging level hierarchically?

Asked by ErikH2000 in Java Programming Language

Tags: log4j, file, properties, write

I would like to use a properties file to configure log4j.  I am wondering how I need to edit the log4j.properties file to accomplish these goals below:

1. Root logger is set to WARN logging level.  So the default logging for any class will always be WARN.
2. Any logging for classes in the hierarchy "com.mycompany.myproject" will have DEBUG logging level.  I don't want to specify every class explicitly in the properties file.
3. Both 1 and 2 are logging to the same appender.

Here is an example properties file that accomplishes #1 above, but not #2.  No logging output for #2 is captured other than WARN level and higher.

log4j.rootLogger=WARN,theappender
log4j.logger.com.thecompany.theproject=DEBUG,theappender

log4j.appender.theappender.layout=org.apache.log4j.PatternLayout
log4j.appender.theappender.layout.ConversionPattern=%d{ISO8601} %-5p - %m%n
log4j.appender.theappender=org.apache.log4j.RollingFileAppender
log4j.appender.theappender.File=/tmp/theappender.log
log4j.appender.theappender.MaxFileSize=500KB
log4j.appender.theappender.MaxBackupIndex=50
Start Free Trial
 
Loading Advertisement...
 
[+][-]07.25.2007 at 02:18PM PDT, ID: 19569903

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Programming Language
Tags: log4j, file, properties, write
Sign Up Now!
Solution Provided By: CEHJ
Participating Experts: 2
Solution Grade: B
 
 
[+][-]07.25.2007 at 02:28PM PDT, ID: 19569976

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2007 at 03:15PM PDT, ID: 19570296

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.25.2007 at 05:38PM PDT, ID: 19571121

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.25.2007 at 05:46PM PDT, ID: 19571153

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.26.2007 at 07:16AM PDT, ID: 19574645

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.26.2007 at 09:22AM PDT, ID: 19575933

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.26.2007 at 03:23PM PDT, ID: 19578844

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.26.2007 at 03:28PM PDT, ID: 19578878

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.23.2007 at 03:22PM PDT, ID: 19758330

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.17.2007 at 12:08PM PDT, ID: 19907411

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32