Each enabled logging request for a given logger will be forwarded to all
the appenders in that logger as well as the appenders higher in the
hierarchy.  In other words, appenders are inherited additively from the
logger hierarchy. For example, if a console appender is added to the
root logger, then all enabled logging requests will at least print on
the console. If in addition a file appender is added to a logger, say X,
then enabled logging requests for X and X's children will print on a
file and on the console.

For a more detailed explanation see
http://logging.apache.org/log4net/release/manual/introduction.html#HC-71
89308

In your case you only need to specify the <appender-ref> in the <root>
element.

Nicko

> -----Original Message-----
> From: Sunil Bhujle [mailto:[EMAIL PROTECTED] 
> Sent: 09 February 2005 21:31
> To: log4net-user@logging.apache.org
> Cc: Sunil Bhujle
> Subject: Duplicate Log statements
> 
> I have recently started using log4Net and our intent is to 
> use it for logging on an engineering application that we are 
> developing.
> I have run into the following problem:
> -I have two levels of logging defined in my config file. One 
> level for my client app and another for an assembly dll that 
> this exe uses.
> -When I try to log using logger.Info("log something") in the 
> client.exe I get the follwing output in my logFile
> 2005-02-09 15:26:53,918 INFO MyLogger 
> [MetToledoScale.TestScale][TestScale_Load] - Client did something
> 2005-02-09 15:26:53,918 INFO MyLogger 
> [MetToledoScale.TestScale][TestScale_Load] - Client did something
> 
> The same statement appears twice.
> 
> - Now when I make the same call in the dll it appears three 
> times as follows:
> 2005-02-09 15:26:54,089 INFO MyLogger.Scale 
> [BSC.EE.Devices.Scale.MettlerToledoMX5][.ctor] - dll did something
> 2005-02-09 15:26:54,089 INFO MyLogger.Scale 
> [BSC.EE.Devices.Scale.MettlerToledoMX5][.ctor] - dll did something
> 2005-02-09 15:26:54,089 INFO MyLogger.Scale 
> [BSC.EE.Devices.Scale.MettlerToledoMX5][.ctor] - dll did something
> 
> 
> Is there any way to prevent the duplicates?
> 
> Here is my config file:
> 
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
> 
>  <configSections>
>               <section name="log4net"
> type="log4net.Config.Log4NetConfigurationSectionHandler,log4ne
> t-net-1.1"/>
>  </configSections>
> 
> <log4net>
>       
>       <root>
>               <appender-ref ref="FileAppender" />
>       </root>
>       
>       <logger name="MyLogger"> 
>               <level value="Info" />
>               <appender-ref ref="FileAppender" />
>       </logger>       
> 
>       <logger name="MyLogger.Scale"> 
>               <level value="Info" />
>               <appender-ref ref="FileAppender" />
>       </logger>       
> 
> 
>       <appender name="FileAppender" 
> type="log4net.Appender.FileAppender">
>               <param name="File" value="LogHelloWorld.log" /> 
>            
>               <param name="AppendToFile" value="true" />
>         <layout type="log4net.Layout.PatternLayout">
>                       <param name="ConversionPattern" 
> value="%d %-p %c [%C][%M] - %m%n" />
>         </layout>
>       </appender>             
>       
> 
> </log4net>
> 
> </configuration>
> 
> 
> 
> 
>               
> __________________________________
> Do you Yahoo!? 
> All your favorites on one personal page - Try My Yahoo!
> http://my.yahoo.com
> 

Reply via email to