Log4net 日志记录配置信息

时间:2021-04-14 14:49:51
<log4net>
<!--配置日志的级别,低于此级别的就不写到日志里面去
OFF、FATAL、ERROR, WARN, INFO, DEBUG, ALL
-->
<root>
<level value="DEBUG" />
<appender-ref ref="LogFileAppender" />
<appender-ref ref="ConsoleAppender" />
</root> <logger name="WebLogger">
<level value="ERROR" />
</logger> <!--输出到文件-->
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
<param name="File" value="Log/" />
<param name="AppendToFile" value="true" />
<!-- 切割最多文件数 -1表示不限制产生日志文件数-->
<param name="MaxSizeRollBackups" value="-1"/>
<!-- 每个文件的大小限制 -->
<param name="MaximumFileSize" value="10MB"/>
<!-- RollingStyle Composite 综合 Size 按大小 Date 按时间 -->
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="&quot;Logs_&quot;yyyyMMdd&quot;.txt&quot;" />
<param name="StaticLogFileName" value="false" />
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="Header" value=" ----------------------application startup-------------------------- " />
<param name="Footer" value=" ----------------------application shutdown-------------------------- " />
<param name="ConversionPattern" value="%d [%t] %-5p %c - (%line) %m%n" />
</layout> <filter type="log4net.Filter.LevelRangeFilter">
<param name="LevelMin" value="ALL" />
<param name="LevelMax" value="OFF" />
</filter>
</appender> <!--输出控制台-->
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender,log4net">
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d [%t] %-5p %c - (%line) %m%n" />
</layout>
</appender> </log4net>