Log4net停止记录到文件

时间:2014-06-20 16:32:30

标签: log4net log4net-configuration

这是我们正在使用的设置,不知道为什么这不起作用。

班级档案

const string conpath = @"configfiles\log4net.config";

XmlConfigurator.Configure(new FileInfo(conpath));

的AssemblyInfo.cs

[assembly: log4net.Config.XmlConfigurator(ConfigFile = @"configfiles\log4net.config", Watch = true)]

log4net.config

<?xml version="1.0" encoding="utf-8" ?>
<log4net>

  <!-- appender section -->
  <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="[%date{MM/dd/yyyy HH:mm:ss.fff}]: %message%newline%exception"/>
    </layout>
  </appender>

  <appender name="DebugAppender" type="log4net.Appender.DebugAppender">
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%m%n%exception" />
    </layout>
  </appender>

  <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
    <file type="log4net.Util.PatternString">
      <conversionPattern value=".\LogFiles\log" />
    </file>
    <appendToFile value="true" />
    <staticLogFileName value="false" />
    <rollingStyle value="Date" />
    <datePattern value=" - yyyy.MM.dd'.txt'"/>
    <layout type="log4net.Layout.PatternLayout">
      <header value="[LOG FILE STARTED]&#13;&#10;&#13;&#10;" />
      <conversionPattern value="%date{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %message%newline" />
      <footer value="&#13;&#10;[LOG FILE FINISHED]&#13;&#10;" />
    </layout>
  </appender>


  <root>
    <level value="DEBUG"/>
    <appender-ref ref="ConsoleAppender"/>
    <appender-ref ref="DebugAppender"/>
    <appender-ref ref="RollingFileAppender"/>
  </root>
</log4net>

0 个答案:

没有答案