log4net按级别分文件夹记录日志
1 <?xml version="1.0"?> 2 <configuration> 3 <configSections> 4 <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> 5 </configSections> 6 <log4net> 7 <!-- OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL --> 8 <!-- Set root logger level to ERROR and its appenders --> 9 <root> 10 <level value="ALL"/> 11 <appender-ref ref="InfoAppender"/> 12 <appender-ref ref="ErrorAppender"/> 13 </root> 14 15 <!-- Print only messages of level DEBUG or above in the packages --> 16 <logger name="WebLogger"> 17 <level value="ALL"/> 18 </logger> 19 <appender name="InfoAppender" type="log4net.Appender.RollingFileAppender,log4net" > 20 <param name="File" value="Log/Info/" /> 21 <param name="AppendToFile" value="true" /> 22 <param name="RollingStyle" value="Date" /> 23 <param name="DatePattern" value=""Log_"yyyyMMdd".txt"" /> 24 <param name="StaticLogFileName" value="false" /> 25 <layout type="log4net.Layout.PatternLayout,log4net"> 26 <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" /> 27 <param name="Header" value=" **************************header************************** " /> 28 <param name="Footer" value=" **************************footer************************** " /> 29 </layout> 30 <filter type="log4net.Filter.LevelRangeFilter"> 31 <param name="LevelMin" value="INFO" /> 32 <param name="LevelMax" value="INFO" /> 33 </filter> 34 </appender> 35 <appender name="ErrorAppender" type="log4net.Appender.RollingFileAppender,log4net" > 36 <param name="File" value="Log/Error/" /> 37 <param name="AppendToFile" value="true" /> 38 <param name="RollingStyle" value="Date" /> 39 <param name="DatePattern" value=""Log_"yyyyMMdd".txt"" /> 40 <param name="StaticLogFileName" value="false" /> 41 <layout type="log4net.Layout.PatternLayout,log4net"> 42 <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" /> 43 <param name="Header" value=" **************************header************************** " /> 44 <param name="Footer" value=" **************************footer************************** " /> 45 </layout> 46 <filter type="log4net.Filter.LevelRangeFilter"> 47 <param name="LevelMin" value="ERROR" /> 48 <param name="LevelMax" value="ERROR" /> 49 </filter> 50 </appender> 51 </log4net> 52 </configuration>