log4net配置

Web.config文件

<configSections>
  <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
</configSections>


<log4net>
  <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
    <file type="log4net.Util.PatternString" value="Log/appLog_%date{yyyyMMdd}.log" />
    <appendToFile value="true" />
    <rollingStyle value="Date" />
    <datePattern value="yyyyMMdd" />
    <layout type="log4net.Layout.PatternLayout">
      <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
    </layout>
  </appender>
  <root>
    <level value="All" />
    <appender-ref ref="LogFileAppender" />
  </root>
</log4net>


AssemblyInfo.cs

[assembly: log4net.Config.XmlConfigurator(Watch = true)]


你可能感兴趣的:(log4net配置)