Rolling File Appender使用示例

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!--In a config file where there will (potentially) be more information stored
beyond just the log4net configuration information,
you will need to specify a section to identify where the log4net configuration is housed.-->
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler,log4net-net-1.0"/>
</configSections>

<log4net>
<root>
<level value="INFO" />
<appender-ref ref="RollingFileAppender" />
</root>

<!--Note that the logger name is the full name of the class including the namespace.
If you wanted to monitor an entire namespace,
it would be as simple as listing just the namespace you wanted to monitor.
I would recommend against trying to re-use appenders in multiple loggers.
It can be done, but you can get some unpredictable results.-->
<logger name="ModemApplication.Logging">
<level value="DEBUG"/>
</logger>

<!--the log file should be capped at 10MB and keep up to 5 archive files
before start deleting them (oldest gets deleted first).
The archives will be named with the same name as the file,
only with a dot and the number after it.-->
<appender name="RollingFileAppender"
type="log4net.Appender.RollingFileAppender" >
<param name="File" value="GetMessage-logfile.txt" />
<param name="AppendToFile" value="true" />
<param name="rollingStyle" valye="Size" />
<param name="maxSizeRollBackups" value="5" />
<param name="maximumFileSize" value="1MB" />
<param name="staticLogFileName" value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern"
value="%date [%thread] %-5level %c - %message %exception%n"
/>
</layout>
<!--When a message fits inside the criteria for a filter,
it is logged and the processing of the filter is finished.-->
<filter type="log4net.Filter.LevelRangeFilter">
<param name="LevelMin" value="INFO" />
<param name="LevelMax" value="FATAL" />
</filter>
<!--its true purpose is to specify that nothing more should be logged -->
<filter type="log4net.Filter.DenyAllFilter" />
</appender>

</log4net>
</configuration>


 

转载于:https://www.cnblogs.com/ttssrs/archive/2012/04/03/2431273.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值