logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Thielen" <da...@windward.net>
Subject RE: Duplicate log entries - 1 last issue
Date Fri, 23 Sep 2005 17:52:33 GMT
Hi;

I think I don't understand <root> and <logger> The way I read the docs
<root> is what is done to all classes for the appenders listed. The <logger>
adds to that.

So I put the following:
	<root>
		<priority value="warn" />
		<appender-ref ref="stdout" />
		<appender-ref ref="tomcat" />
	</root>

Which puts all warn and worse in those 2 appenders. And that works fine.

But then I also want info for org.apache in stdout only. So I add:
	<logger name="org.apache" additivity="false">
		<level value="info"/>
		<appender-ref ref="stdout" />
	</logger>

And now tomcat gets nothing written to it. Why? The <logger> element does
not mention tomcat.

??? - thanks - dave


David Thielen
303-499-2544
www.windwardreports.com

-----Original Message-----
From: James Stauffer [mailto:stauffer.james@gmail.com] 
Sent: Friday, September 23, 2005 7:23 AM
To: Log4J Users List
Subject: Re: Duplicate log entries - 1 last issue

On 9/22/05, David Thielen <david@windward.net> wrote:
> If I have:
>       <logger name=3D"org.apache" additivity=3D"false">
>             <level value=3D"info"/>
>             <appender-ref ref=3D"stdout" />
>       </logger>
> Then nothing is written to the tomcat appender.

Changing that to the following would also send the output to tomcat
       <logger name="org.apache" additivity="false">
             <level value="info"/>
             <appender-ref ref="stdout" />
             <appender-ref ref="tomcat" />
       </logger>

> If I have:
>
>       <logger name=3D"org.apache">
>             <level value=3D"info"/>
>             <appender-ref ref=3D"stdout" />
>       </logger>
>
> Then I get two problems:
>
> First, tomcat now has INFO logging (want that in stdout only). Second,
> stdout gets each entry twice.
To fix the first problem you could set a threshold on the tomcat
appender so it only write warn logs.
    <param name="Threshold" value="warn"/>

To solve the 2nd problem you you need to make sure that either
additivity is false for <logger name="org.apache"> or that tomcat
isn't specified for both <logger name="org.apache"> and <root>.


>
> Log4j.xml:
>
> <?xml version=3D"1.0" encoding=3D"UTF-8" ?> <!DOCTYPE log4j:configuration
> SYSTEM "log4j.dtd"> <log4j:configuration
> xmlns:log4j=3D"http://jakarta.apache.org/log4j/">
>
>
>
>       <appender name=3D"stdout"
>
> class=3D"org.apache.log4j.ConsoleAppender">
>
>             <layout class=3D"org.apache.log4j.PatternLayout">
>
>                   <param name=3D"ConversionPattern" value=3D"%5p [%t] %m -
> %c %M%n"/>
>
>             </layout>
>
>       </appender>
>
>
>
>       <appender name=3D"tomcat"
>
> class=3D"org.apache.log4j.RollingFileAppender">
>
>             <param name=3D"file"
>
> value=3D"${catalina.home}/logs/tomcat.log"/>
>
>             <param name=3D"MaxFileSize" value=3D"100KB"/>
>
>             <param name=3D"MaxBackupIndex" value=3D"10"/>
>
>             <layout class=3D"org.apache.log4j.PatternLayout">
>
>                   <param name=3D"ConversionPattern"
>
> value=3D"%d{HH:mm:ss.SSS} %5p [%t] %c - %m%n"/>
>
>             </layout>
>
>       </appender>
>
>
>
>       <appender name=3D"windward"
>
> class=3D"org.apache.log4j.RollingFileAppender">
>
>             <param name=3D"file"
>
> value=3D"${catalina.home}/logs/windward.log"/>
>
>             <param name=3D"MaxFileSize" value=3D"100KB"/>
>
>             <param name=3D"MaxBackupIndex" value=3D"10"/>
>
>             <layout class=3D"org.apache.log4j.PatternLayout">
>
>                   <param name=3D"ConversionPattern"
>
> value=3D"%d{HH:mm:ss.SSS} %5p [%t] %c - %m%n"/>
>
>             </layout>
>
>       </appender>
>
>
>
>       <logger name=3D"net.windward" additivity=3D"false">
>
>             <level value=3D"info"/>
>
>             <appender-ref ref=3D"windward" />
>
>       </logger>
>
>       <logger name=3D"org.apache">
>
>             <level value=3D"info"/>
>
>             <appender-ref ref=3D"stdout" />
>
>       </logger>
>
>       <root>
>
>             <priority value=3D"warn" />
>
>             <appender-ref ref=3D"stdout" />
>
>             <appender-ref ref=3D"tomcat" />
>
>       </root>
>
>
>
> </log4j:configuration>
>
>
>
>
>
>
>


--
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message