配置lognet的每天产生一个,文件最大的1024K。
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="App_Log\DCServer_"/>
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="100"/>
<param name="MaximumFileSize" value="10MB"/>
<param name="RollingStyle" value="Size" />
<param name="StaticLogFileName" value="false" />
<param name="DatePattern" value="yyyyMMdd".txt"" />
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d [%t] %-5p %c - (%line) %m%n" />
</layout>
</appender>
<!-- 控制台前台显示日志 -->
<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
<mapping>
<level value="ERROR"/>
<foreColor value="Red, HighIntensity"/>
</mapping>
<mapping>
<level value="Info"/>
<foreColor value="Green"/>
</mapping>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%n%date{HH:mm:ss,fff} [%-5level] %m"/>
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<param name="LevelMin" value="Info"/>
<param name="LevelMax" value="Fatal"/>
</filter>
</appender>
<root>
<!--(高) OFF > FATAL > ERROR > WARN > INFO > DEBUG > ALL (低) -->
<level value="all"/>
<appender-ref ref="RollingLogFileAppender"/>
</root>
<logger name="DataRequest">
<level value="DEBUG"/>
<appender-ref ref="ColoredConsoleAppender"/>
</logger>
<logger name="AlarmListen">
<level value="DEBUG"/>
<appender-ref ref="ColoredConsoleAppender"/>
</logger>
<logger name="OPCClient">
<level value="DEBUG"/>
<appender-ref ref="ColoredConsoleAppender"/>
</logger>
</log4net>