• C# log4net


    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <!-- This section contains the log4net configuration settings -->
      <log4net>
    
        <!-- Setup the root category, add the appenders and set the default level -->
        <!--控制级别,由低到高:ALL|DEBUG|INFO|WARN|ERROR|FATAL|OFF-->
        <root>
          <level value="ALL" />
          <appender-ref ref="RollingLogFileAppender" />
        </root>
    
        <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
          <!--最小锁定模型以允许多个进程可以写入同一个文件-->
          <lockingModel  type="log4net.Appender.FileAppender+MinimalLock" />
          <!--日志文件路径-->
          <file value="log//" />
          <!--是否是向文件中追加日志-->
          <appendToFile value="true" />
          <!--日志根据日期滚动-->
          <rollingStyle value="Date" />
          <!--日志文件名是否是固定不变的-->
          <staticLogFileName value="false" />
          <!--日志文件名格式为:2008-08-31.log-->
          <datePattern value="yyyy-MM-dd'.log'" />
          <!--log保留天数-->
          <maxSizeRollBackups value="10" />
          <!--最大文件大小-->
          <maximumFileSize value="1MB" />
          <!--信息日志布局-->
          <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
          </layout>
        </appender>
    
      </log4net>
    </configuration>
    log4net.config

    初始化

                log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo( "C:\log4net.config"));

    实例化对象

            static readonly ILog log = LogManager.GetLogger(typeof(MainService));
  • 相关阅读:
    【已解决】github中git push origin master出错:error: failed to push some refs to
    好记心不如烂笔头,ssh登录 The authenticity of host 192.168.0.xxx can't be established. 的问题
    THINKPHP 5.0目录结构
    thinkphp5.0入口文件
    thinkphp5.0 生命周期
    thinkphp5.0 架构
    Django template
    Django queryset
    Django model
    Python unittest
  • 原文地址:https://www.cnblogs.com/su-king/p/12554116.html
Copyright © 2020-2023  润新知