zoukankan      html  css  js  c++  java
  • log4net配置

    1.configuration配置

      <configSections>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
      </configSections>

    2.Global.asax

            protected void Application_Start()
            {
                //加载log4配置
                log4net.Config.XmlConfigurator.Configure();
            }

    3.configuration的log4net节点

      <log4net>
        <logger name="wolflogInfo">
          <level value="Info" />
          <appender-ref ref="wolflogInfoFileAppender" />
        </logger>
        <logger name="wolflogError">
          <level value="Error" />
          <appender-ref ref="wolflogErrorFileAppender" />
        </logger>
        <logger name="wolflogALL">
          <level value="ALL" />
          <appender-ref ref="wolflogALLFileAppender" />
        </logger>
        <!-- 绑定使用的名称 -->  
        <appender name="wolflogInfoFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
          <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
          <!--输出文件夹路径-->
          <param name="File" type="" value="App_Data/Log/Info/" />
          <param name="AppendToFile" value="true" />
          <param name="RollingStyle" value="Date" />
          <!--文件名称命名规则-->
          <param name="DatePattern" value="yyyyMMdd&quot;.txt&quot;" />
          <param name="StaticLogFileName" value="false" />
          <param name="MaxSizeRollBackups" value="62" />
          <layout type="log4net.Layout.PatternLayout,log4net">
            <!--输出头-->
            <param name="ConversionPattern" value="%n[%d] %c %n%m%n%n" />
          </layout>
        </appender>
        <appender name="wolflogErrorFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
          <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
          <param name="File" type="" value="App_Data/Log/Error/" />
          <param name="AppendToFile" value="true" />
          <param name="RollingStyle" value="Date" />
          <param name="DatePattern" value="yyyyMMdd&quot;.txt&quot;" />
          <param name="StaticLogFileName" value="false" />
          <param name="MaxSizeRollBackups" value="62" />
          <layout type="log4net.Layout.PatternLayout,log4net">
            <param name="ConversionPattern" value="%n[%d] %c %n%m%n%n" />
          </layout>
        </appender>
        <appender name="wolflogALLFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
          <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
          <param name="File" type="" value="App_Data/Log/ALL/" />
          <param name="AppendToFile" value="true" />
          <param name="RollingStyle" value="Date" />
          <param name="DatePattern" value="yyyyMMdd&quot;.txt&quot;" />
          <param name="StaticLogFileName" value="false" />
          <param name="MaxSizeRollBackups" value="62" />
          <layout type="log4net.Layout.PatternLayout,log4net">
            <param name="ConversionPattern" value="%n[%d] %c %n%m%n%n" />
          </layout>
        </appender>
      </log4net>

    4.调用

                ILog log = log4net.LogManager.GetLogger("wolflogInfo");
                log.Info("输出点东西Info");
                log.Error("输出点东西Error");
                ILog log1 = log4net.LogManager.GetLogger("wolflogError");
                log1.Info("输出点东西Info");
                log1.Error("输出点东西Error");
                ILog log2 = log4net.LogManager.GetLogger("wolflogALL");
                log2.Info("输出点东西Info");
                log2.Error("输出点东西Error");

    效果

     

  • 相关阅读:
    BZOJ4889: [TJOI2017]不勤劳的图书管理员
    BZOJ3932: [CQOI2015]任务查询系统
    BZOJ1926: [Sdoi2010]粟粟的书架
    POJ 3281 Dining(网络流-拆点)
    POJ 1273 Drainage Ditches(网络流-最大流)
    POJ 1325 Machine schedine (二分图-最小点覆盖数=最大匹配边数)
    HDU 1281 棋盘游戏
    HDU2255 奔小康赚小钱钱(二分图-最大带权匹配)
    HDU 2444 The Accomodation of Students (二分图存在的判定以及最大匹配数)
    POJ 3660 cow contest (Folyed 求传递闭包)
  • 原文地址:https://www.cnblogs.com/lgxlsm/p/6253473.html
Copyright © 2011-2022 走看看