Search code examples
.net.net-corebufferlog4netlog4net-appender

log4net BufferingForwardingAppender appender looks like not working in .net core 2.1


I am doing logging for my .net core console application from log4net. simple RollingFileAppender file logging works. Now i wanted to extend it via bufferforwardingappender but logs not adding in the file. Please let me know what could be configuration error in my log4net settings

<?xml version="1.0" encoding="utf-8" ?>
<log4net>
  <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender" >
    <file value="NetMQBroker" />
    <encoding value="utf-8" />
    <appendToFile value="true" />
    <datePattern value="_yyyyMMdd'.log'" />
    <staticLogFileName value="false" />
    <rollingStyle value="Composite"/>
    <maxSizeRollBackups value="-1"/>
    <maximumFileSize value="10MB"/>
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <filter type="log4net.Filter.LevelRangeFilter">
      <acceptOnMatch value="true" />
      <levelMin value="DEBUG" />
      <levelMax value="FATAL" />
    </filter>
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%d{yyyy-MM-dd HH:mm:ss.fff}&#9;%p&#9;AuthCoreApi&#9;%t&#9;%property{Ip}&#9;%property{Context}&#9;%property{ContextId}&#9;%c{1}&#9;%m%n" />
    </layout>
  </appender> 
  <appender name="MyBufferingAppender" type="log4net.Appender.BufferingForwardingAppender">
    <bufferSize value="1" />
    <lossy value="true" />   
    <appender-ref ref="RollingLogFileAppender" />
  </appender>
  <root>
    <level value="ALL" />    
    <appender-ref ref="MyBufferingAppender" />
     <!--<appender-ref ref="RollingLogFileAppender" />-->
  </root>
</log4net>

Solution

  • It looks like lossy value is the culprit. have set it to false and logs get output

    <lossy value="false" />