0

I have WPF application with Log4Net log:

  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>

  <log4net>
    <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
      <file type="log4net.Util.PatternString" value="%property{LogFileName}.txt" />
      <rollingStyle value="Date" />
      <appendToFile value="true" />
      <rollingStyle value="Size"/>
      <maximumFileSize value="10MB"/>
      <maxSizeRollBackups value="5"/>
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
      <datePattern value="yyyyMMdd" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="[%date] [%level] [%logger/%method] - %message%newline%exception"/>
      </layout>
    </appender>    

    <root>
      <level value="DEBUG"/>
      <appender-ref ref="RollingFile" />
    </root>
  </log4net>

So the Log path is the application folder and i can open my application more then once so my question is what could happen if 2 instances of my application report to the same log ?

Maybe i need to lock or something to avoid race condition ??

Dim Mark
  • 73
  • 2
  • 8
  • Is it a requirement to log to the same file? If not I strongly recommend against it; reading the log is much easier if it just contains line from a single instance – Emond Mar 24 '18 at 14:32
  • Not a requirement, so if my application could start with several instances what could be the solution ? – Dim Mark Mar 24 '18 at 14:50
  • See the question/answer at the top of this page. – Emond Mar 24 '18 at 15:06

0 Answers0