You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Sunil Bhujle <su...@yahoo.com> on 2005/02/09 22:30:32 UTC

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,log4net-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