zoukankan      html  css  js  c++  java
  • 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>


     

  • 相关阅读:
    2020软件工程作业04
    2020软件工程作业03
    2020软件工程作业02
    2020软件工程作业01
    2020软件工程作业02
    2020软件工程作业01
    WEB学习路线2019完整版(附视频教程+网盘下载地址)
    (2018干货系列七)最新大数据学习路线整合
    (2018干货系列六)最新云计算学习路线整合
    (2018干货系列五)最新UI设计学习路线整合
  • 原文地址:https://www.cnblogs.com/ttssrs/p/2431273.html
Copyright © 2011-2022 走看看