<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
  </configSections>
  <log4net>
    <root>
      <level value="ALL" />
      <appender-ref ref="LogFileAppender" />
      <!--<appender-ref ref="EventLogAppender" />-->
    </root>
    <!--定义输出到文件-->
    <appender name ="LogFileAppender" type="nebula.MyRollingFileAppender">
      <!--定义文件存放位置-->
      <param name="File" value ="Logs/nebula/"/>
      <param name="AppendToFile" value="true" />
      <param name="MaxSizeRollBackups" value="100" />
      <param name="MaxFileSize" value="10240" />
      <param name="StaticLogFileName" value="false" />
	
	    <param name="OutDateDays" value="2"/>
      <param name="MaximumFileCount" value="5"/>
      <param name="DeleteStyle" value="LastWriteTime"/>
      
      <!--文件名格式-->
      <param name="DatePattern" value="yyyy.MM.dd'.log'" />
      <param name="RollingStyle" value ="Date" />
      <!--不以独占方式记录日志,仅在记录每个日志的最短时间内锁定,因为部署到服务器上遇到了文件被占用无法下载日志-->
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
      <layout type="log4net.Layout.PatternLayout">
        <!--定义输出格式-->
        <!--示例 2018-08-20 12:10:49,348 -线程ID:[21] 日志级别:[INFO ] : [日志信息]-->
        <param name="ConversionPattern" value="%date 线程ID:[%thread] 日志级别:[%-5level] : [%message]%newline"/>
      </layout>

      <!--设置某命名空间下的类不打印日志-->
      <filter type="log4net.Filter.LoggerMatchFilter">
        <param name="LoggerToMatch" value="Hangfire.Server" />
        <param name="AcceptOnMatch" value="false" />
      </filter>

      <!--过滤级别 FATAL > ERROR > WARN > INFO > DEBUG-->
      <filter type="log4net.Filter.LevelRangeFilter">
        <param name="LevelMin" value="DEBUG" />
        <param name="LevelMax" value="FATAL" />
      </filter>
    </appender>
    <!--定义输出到 windows 事件中-->
    <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"></conversionPattern>
      </layout>
    </appender>
  </log4net>
</configuration>