It shouldn't. Maybe you are not fetching the logger correctly. How you
instantiate the logger in the Main class? It should be:
Logger.getLogger( "loggingexample.Main" )
or
Logger.getLogger( this.getClass() )
The latter is only valid if "loggingexample.Main" is exactly the FQCN of MAIN
(normally there is a a toplevel domain in front, i.e.
"com.loggingexample.Main").
Try it with annother appender (maybe FileAppender) for the
"loggingexample.Main"-Logger. So you can see which logger outputs the event.
Heri
> -----Original Message-----
> From: chuanjiang lo [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 05, 2006 12:30 PM
> To: Log4J Users List
> Subject: Re: Setting up log4j.xml
>
>
> On 12/5/06, Bender Heri <[EMAIL PROTECTED]> wrote:
> >
> > 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
>
>
> This is my current xml configuration..somehow the class Main
> still prints
> out those levels that are below error.
>
> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
> debug="false">
>
> <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" additivity="false">
> <level value="error"/>
> <appender-ref ref="A1"/>
> </logger>
>
> <root>
> <level value="debug"/>
> <appender-ref ref="A1"/>
> </root>
> </log4j:configuration>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]