log4net BufferingForwardingAppender附加程序看起来无法在.net core 2.1中运行

时间:2019-04-24 11:28:16

标签: .net .net-core buffer log4net log4net-appender

我正在从log4net记录.net核心控制台应用程序。简单的RollingFileAppender文件记录功能。现在,我想通过bufferforwardingappender扩展它,但是日志未添加到文件中。 请让我知道我的log4net设置中可能是配置错误

<?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>

1 个答案:

答案 0 :(得分:0)

看来,有损价值是罪魁祸首。将其设置为false并获取输​​出日志

<lossy value="false" />