zoukankan      html  css  js  c++  java
  • log4Net 简单配置实用

      <configSections>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
      </configSections>
    View Code
      <log4net debug="false">
        <appender name="LogFileAppender" type="log4net.Appender.FileAppender" >
          <!--日志存放位置-->
          <param name="File" value="c:ResourceMgrLog" />
          <param name="datePattern" value="yyyy-MM-dd HH:mm" />
          <param name="AppendToFile" value="true" />
          <param name="MaxSizeRollBackups" value="10" />
          <param name="MaximumFileSize" value="5MB" />
          <param name="StaticLogFileName" value="false" />
          <param name="DatePattern" value="yyyy-MM-dd.LOG" />
          <layout type="log4net.Layout.PatternLayout">
            <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
          </layout>
        </appender>
        <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
          <!--日志存放位置-->
          <param name="File" value="C:ResourceMgrLog" />
          <param name="AppendToFile" value="true" />
          <param name="StaticLogFileName" value="false" />
          <param name="DatePattern" value="yyyy-MM-dd.LOG" />
          <param name="MaxSizeRollBackups" value="10" />
          <param name="MaximumFileSize" value="5MB" />
          <param name="RollingStyle" value="Date" />
          <layout type="log4net.Layout.PatternLayout">
            <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
          </layout>
        </appender>
        <root>
          <level value="DEBUG" />
          <appender-ref ref="LogFileAppender" />
          <appender-ref ref="RollingLogFileAppender" />
        </root>
      </log4net>
    View Code

    Global.asax中的 Application_Start方法下添加:

    log4net.Config.XmlConfigurator.Configure();
     private static readonly ILog log = LogManager.GetLogger(typeof(FixedAssetManagement));
    
    log.Debug("",ex);
  • 相关阅读:
    POJ_1523 SPF (Tarjan 求割点)
    POJ 3177&& 3352
    POJ 基础数据结构
    Bellman Ford, SPFA 学习笔记(含有负权的单源最短路径)
    HDU_3062 Party (2SAT)
    POJ二分图最大匹配的简单题目
    POJ 2553 The Bottom of a Graph (Trajan 强连通分量 缩点)
    POJ_3678 Katu Puzzle (2SAT)
    HDU_3836 Equivalent Set (Trajan 强连通分量 缩点)
    POJ1904 King's Quest(Tarjan 求缩点)
  • 原文地址:https://www.cnblogs.com/fangyangwa/p/4179915.html
Copyright © 2011-2022 走看看