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>


     

  • 相关阅读:
    Java之抽象类,多态,接口
    Java之抽象类,多态
    Java之类。实例初始化
    Java基础之继承
    java面向对象之工具类
    Java基础面向对象封装
    Python入门学习资料推荐
    内网安全「攻防」学习指南
    windows文件扩展名
    java 的包命名规范
  • 原文地址:https://www.cnblogs.com/ttssrs/p/2431273.html
Copyright © 2011-2022 走看看