• Common.Logging.dll----------配置方式,可选引用,用于日志输出


    1.简介
    common logging是一个通用日志接口,log4net是一个具体实现. common logging可以把输出连接到其他非log类上, 如EntLib的日志、NLog等

    2.使用
    接下来介绍的是和log4net一起使用的介绍.
    #程序中需要引入的:
    #Common.Logging.dll
    #Common.Logging.Log4Net.dll
    #log4net.dll

    Common.Logging.ILog logger = Common.Logging.LogManager.GetLogger(Assembly.GetExecutingAssembly().GetName().Name);
    logger.Info("shutdown quartz.");
    logger.Debug("shutdown quartz.");

    3.配置
    在app.config或者web.config中,加入:
        <configSections>
            <sectionGroup name="common">
                <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
            </sectionGroup>
            <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
        </configSections>

        <common>
            <logging>
                <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
                    <arg key="configType" value="INLINE" />
                </factoryAdapter>
            </logging>
        </common>
        
        <log4net>
            <appender name="LogFileAppender" type="log4net.Appender.FileAppender">
                <param name="File" value="log.txt"/>
                <param name="datePattern" value="MM-dd HH:mm"/>
                <param name="AppendToFile" value="true"/>
                <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" />
            </root>
        </log4net>
     
    关于log4net的详细设置,请参考http://blog.sina.com.cn/s/blog_ad0672d60101ko49.html

  • 相关阅读:
    mybatis SQL 根据in条件语句排序
    Redis面试总结
    数据库优化之分库分表
    jdk1.6 Synchronized 优化总结
    CounDownLatch、CyclicBarrier、Semaphore
    java锁总结
    Redis 与 MySQL 双写一致性如何保证
    dubbo总结
    一、全国大学生电子设计竞赛测控(无人机)方向___基础篇
    编解码KL变换详解和哥伦布k阶编解码
  • 原文地址:https://www.cnblogs.com/weber4444/p/6490440.html
Copyright © 2020-2023  润新知