You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Randall Ballew <rb...@intraware.com> on 2001/01/08 20:18:08 UTC

newbie question

Hi,

I'm trying to set up log4j (v0.9.1) as follows:

Category 1 -- com.intraware.logging,                 log ERROR and above

to syslog  (SYSLOG)
Category 2 -- com.intraware.logging.app           log WARN and above to
rolling file. (APP_FILE_LOG)
Category 3 -- com.intraware.logging.app.trace   log all to STDERR

With the attached properties file and test program, INFO and DEBUG
messages  are appended to APP_FILE_LOG.
Desired behavior occurs when the Threshold option is set
explicitly by uncommenting:

         # log4j.appender.APP_FILE_LOG.Threshold=WARN

Thanks for any help.

Randy


--
Randy Ballew, Senior Application Architect, Intraware, Inc.
    925.253.4507
    rballew@intraware.com


Re: newbie question

Posted by Ceki Gulcu <cg...@urbanet.ch>.
Randy,

This is a classic. Here is an excerpt from the log4j troubleshooting guide 
(http://log4j.sourceforge.net/log4j/TROUBLESHOOT.html#duplicates)
One other common mistake is to forget that appenders are inherited 
cumulatively from the hierarchy. For example, if you add an appender, say 
A, to the root category, all
other categories will inherit A as an appender. Thus, if you add A to a 
categoy, say C, then an enabled statement of category C, will print to A 
twice, once because A is in
root and once because it is in C.

In your case, the com.intraware.logging.app.trace category is inheriting 
the APP_FILE_LOG and SYSLOG appenders from the  com.intraware.logging.app 
and respectively the com.intraware.logging categories.

You can add a Threshold to APP_FILE_LOG as you have done or set the 
additivity flag of the com.intraware.logging.app.trace category to false. 
This will prevent the com.intraware.logging.app.trace category from 
inheriting appenders from higher in the hierarchy.

The syntax is:

log4j.additivity.com.intraware.logging.app.trace=false

I hope this helps, Ceki

At 11:18 08.01.2001 -0800, you wrote:

>Hi,
>
>I'm trying to set up log4j (v0.9.1) as follows:
>
>Category 1 -- com.intraware.logging,                 log ERROR and above
>
>to syslog  (SYSLOG)
>Category 2 -- com.intraware.logging.app           log WARN and above to
>rolling file. (APP_FILE_LOG)
>Category 3 -- com.intraware.logging.app.trace   log all to STDERR
>
>With the attached properties file and test program, INFO and DEBUG
>messages  are appended to APP_FILE_LOG.
>Desired behavior occurs when the Threshold option is set
>explicitly by uncommenting:
>
>          # log4j.appender.APP_FILE_LOG.Threshold=WARN
>
>Thanks for any help.
>
>Randy
>
>
>--
>Randy Ballew, Senior Application Architect, Intraware, Inc.
>     925.253.4507
>     rballew@intraware.com
>
>#log4j.configDebug
>log4j.appender.SYSLOG=org.log4j.net.SyslogAppender
>log4j.appender.SYSLOG.SyslogHost=localhost
>log4j.appender.SYSLOG.layout=org.log4j.PatternLayout
>log4j.appender.SYSLOG.layout.ConversionPattern=[%t] %-5p - %m%n
>
>log4j.appender.APP_FILE_LOG=org.log4j.RollingFileAppender
>log4j.appender.APP_FILE_LOG.File=appl.log
>log4j.appender.APP_FILE_LOG.layout=org.log4j.PatternLayout
>log4j.appender.APP_FILE_LOG.layout.ConversionPattern=%d [%t] %-5p - %m%n
>log4j.appender.APP_FILE_LOG.MaxFileSize=1KB
>log4j.appender.APP_FILE_LOG.MaxBackupIndex=3
>#log4j.appender.APP_FILE_LOG.Threshold=WARN
>
>log4j.appender.STDERR=org.log4j.FileAppender
>log4j.appender.STDERR.File=System.err
>log4j.appender.STDERR.layout=org.log4j.PatternLayout
>log4j.appender.STDERR.layout.ConversionPattern=%d [%t] %-5p - %m%n
>
>log4j.category.com.intraware.logging=ERROR,SYSLOG
>log4j.category.com.intraware.logging.app=WARN,APP_FILE_LOG
>log4j.category.com.intraware.logging.app.trace=INFO,STDERR
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org