Log events which are sent to a specialized Logger (=not Root Logger) will by 
default climb up the logger hierarchy until the root logger and serve every 
appender of every logger found on its way. Your example: a log event sent to 
logger named "loggingexample.Main" arrieves to this logger, does not find an 
appender, looks up the next upper logger in hierarchy, finds the root logger 
with level DEBUG and serves its appender A1.

To achieve what you want, supply the logger "loggingexample.Main" with the 
appender-ref A1 and set the logger's property additivity=false. This will 
prevent the log event to climb further up the hierarchy.

    <logger name="loggingexample.Main" additivity="false">
         <level value="error"/>
         <appender-ref ref="A1" />
     </logger>

Heri

> -----Original Message-----
> From: chuanjiang lo [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 05, 2006 7:59 AM
> To: Log4J Users List
> Subject: [SPAM (Bayesain Analysis)] - Re: Setting up log4j.xml -
> Bayesian Filter detected spam
> 
> 
> i'm having this config..
> i would like to print out error and fatal msgs in the Main class of
> loggingexample package, how come it is still printing debug 
> level and above
> msgs?
> 
> appreciate any help
> 
>     <appender name="A1" class="org.apache.log4j.ConsoleAppender">
>         <layout class="org.apache.log4j.PatternLayout">
>             <!-- Print the date in ISO 8601 format -->
>             <param name="ConversionPattern" value="%d [%t] 
> %-5p %c - %m%n"/>
> 
>         </layout>
>     </appender>
> 
>    <logger name="loggingexample.Main">
>         <level value="error"/>
>     </logger>
> 
>     <root>
>         <level value="debug"/>
>         <appender-ref ref="A1" />
>     </root>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to