Paul,

Thanks for the response.

Each of the assemblies is configured via the following entries in the 
AssemblyInfo.cs file:

        [assembly: log4net.Config.Repository]
        [assembly: log4net.Config.XmlConfigurator(ConfigFile = 
"my-assembly-log4net.config")]

I've tried changing the "conversionPattern" to determine which appender 
definition is being used.  It is always using the application's appender 
definition.  All output is going to the output file defined there.

Any class that needs to log will have a static member like this:

        private static readonly ILog DebugLog = 
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

-Mat

-------
From: Paul Dejardin [mailto:pdejar...@factset.com] 
Sent: Friday, April 27, 2012 7:56 AM
To: Log4NET User
Subject: RE: Duplicate log entries with DLL/EXE combination

How are you configuring? (programmatically, custom attribute, etc.) My guess 
would be that the 'DebugAppender' is being added twice (once in two separate 
repositories). You could use the same Repository for both assemblies. How are 
you creating loggers in code?

-------
From: Kramer, Mat [mailto:mkra...@datasci.com] 
Sent: Thursday, April 26, 2012 7:02 PM
To: log4net-user@logging.apache.org
Subject: Duplicate log entries with DLL/EXE combination

Hello,

We have a .NET executable and a DLL assembly that both use log4net.  One of the 
complications is that the DLL is also called from an unmanaged C++ application 
and we want logging to work in that setting.  Our current solution works, but I 
get many duplicate log entries when I am running the .NET EXE with the .NET 
DLL.  The configurations are below.  Any ideas for how to fix this?  I have to 
admit I don't really understand how it works now.

Thanks!

Application configuration

<log4net>

  <appender name="DebugAppender" type="log4net.Appender.RollingFileAppender">
    <file value="log-file-fauxnemah.txt" />
    <appendToFile value="true" />
    <rollingStyle value="Size" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="50MB" />
    <staticLogFileName value="true" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date %7level [%2thread] %message%newline" />
    </layout>
  </appender>

  <root>
    <level value="ALL" />
    <appender-ref ref="DebugAppender" />
  </root>

</log4net>

DLL configuration

<log4net>

  <appender name="DebugAppender" type="log4net.Appender.RollingFileAppender">
    <file value="TruSense//log-file-trusenseP3P.txt" />
    <appendToFile value="true" />
    <rollingStyle value="Size" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="50MB" />
    <staticLogFileName value="true" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date %7level [%2thread] %message%newline" />
    </layout>
  </appender>

  <root>
    <level value="ALL" />
    <appender-ref ref="DebugAppender" />
  </root>

  <logger name="DSI.DACSS.Transformers.FahiTransformer" additivity="false">
    <level value="NONE" />
  </logger>

  <logger name="DSI.DACSS.Framework.Logger.SystemLogger" additivity="false">
    <level value="ALL" />
    <appender-ref ref="DebugAppender" />
  </logger>

</log4net>


-Mat

Reply via email to