zoukankan      html  css  js  c++  java
  • 日志管理

    采用log4net+Common.Logging.Log4Net

    1、Nuget:Common.Logging.Log4Net208 自动下载完四个包

    2、配置config 

    Common:

    <sectionGroup name="common">
          <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
        </sectionGroup>

    <!--与log4net关联-->
    <common>
    <logging>
    <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net208">
    <arg key="configType" value="FILE-WATCH" />
    <arg key="configFile" value="~/Conf/log4net.config" />
    <arg key="level" value="INFO" />
    </factoryAdapter>
    </logging>
    </common>

    Log4net:log4net.config

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

    <root>
    <level value="ALL"/>
    <appender-ref ref="LogFileAppender"/>
    </root>
    <appender name="LogFileAppender" type="log4net.Appender.FileAppender">
    <param name="File" value="my_log-file.txt"/>
    <param name="AppendToFile" value="true"/>
    <layout type="log4net.Layout.PatternLayout">
    <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n"/>

    </layout>

    </appender>

    <logger name="yateJob" additivity="false" >
    <level value="ALL" />
    <appender-ref ref="yateJobTxtAppender" />
    </logger>
    </log4net>
    </configuration>

     log4初始化:log4net.Config.XmlConfigurator.Configure();

    3、扩展

  • 相关阅读:
    centos7开启关闭防火墙
    虚拟机vmnet1和vmnet8找不到,注册表没有删除干净,见图
    dhcp和static的区别
    SQL手册
    canal架构原理
    SQL优化(待完善)
    数仓简介
    java逆变与协变(待完善)
    mysqljoin的原理和优化
    深入理解java虚拟机阅读笔记
  • 原文地址:https://www.cnblogs.com/zzfy/p/9652338.html
Copyright © 2011-2022 走看看