0

I set the app.config for log4net as below in order to log some message every changed status.

I input additivity="false" after googling, but the duplicated message is still logged.

Would you please advice me to correct the below config so that duplicated message can be disapprearing?

<appender name="APP_TRACE_ONCE_LOG_EVENTREF" type="log4net.Appender.RollingFileAppender" additivity="false">
  <File value="C:\Edwards\HMI\Test\TraceOnce\"/>
  <AppendToFile value="true"/>
  <MaxSizeRollBackups value="100"/>
  <DatePattern value="TraceOnce_dd.MM.yyyy.'log'"/>
  <MaximumFileSize value="512KB"/>
  <RollingStyle value="Composite"/>
  <StaticLogFileName value="false"/>
  <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
  <layout type="log4net.Layout.PatternLayout">
    <ConversionPattern value="[%-5p][%d]-[%m]%n"/>
  </layout>
</appender>

<logger name="APP_TRACE_ONCE_LOG_CONFIG">
  <level value="ALL"/>
  <appender-ref ref="APP_TRACE_ONCE_LOG_EVENTREF"/>
</logger>
  • * if the below steps are executed like HmiLog.Debug("Message A..."); HmiLog.Debug("Message A..."); HmiLog.Debug("Message A..."); HmiLog.Debug("Message B..."); HmiLog.Debug("Message B..."); HmiLog.Debug("Message C..."); HmiLog.Debug("Message C..."); HmiLog.Debug("Message A..."); the message should be logged like Message A... Message B... Message C... Message A... in text file after removing duplicated messages. – Sean.Pyeon Jul 27 '19 at 13:24
  • You have added additivity to the appender, but it should be on the logger, see the example on Eddie's answer to https://stackoverflow.com/questions/651277/eliminate-duplicate-logging-in-log4net#661903 – sgmoore Jul 30 '19 at 10:26

0 Answers0