• Log4net记录日志存库并存本地


    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
      </configSections>
      <!--Log4net Begin-->
      <log4net>
        <root>
          <!--控制级别,由低到高: all|debug|info|warn|error|fatal|off-->
          <level value="All"/>
          <appender-ref ref="rollinglogfileappender" />
          <appender-ref ref="consoleappender" />
          <appender-ref ref="adonetappender_mysql"/>
        </root>
        <!--<logger name="LogWriter">
          <level value="ALL"/>
          <appender-ref ref="ADONetAppender"/>
          <appender-ref ref="RollingLogFileAppender" />
        </logger>-->
        <appender name="AdoNetAppender_MySql" type="log4net.Appender.ADONetAppender">
          <bufferSize value="1" />
          <connectionType value="MySql.Data.MySqlClient.MySqlConnection, MySql.Data" />
          <connectionString value="server=172.16.13.165;user id=microask;pwd=123456;port=3306;pooling=True;database=microask2" providerName="MySql.Data.MySqlClient;" />
          <commandText value=" INSERT INTO t_system_log (Date1,Thread,Level,Logger,Message,Exception) VALUES (@Date1, @Thread, @Level, @Logger, @Message, @Exception)" />
          <parameter>
            <parameterName value="@Date1" />
            <dbType value="String" />
            <layout type="log4net.Layout.RawTimeStampLayout" />
          </parameter>
          <parameter>
            <parameterName value="@Thread" />
            <dbType value="String" />
            <size value="100" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%thread" />
            </layout>
          </parameter>
          <parameter>
            <parameterName value="@Level" />
            <dbType value="String" />
            <size value="100" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%level" />
            </layout>
          </parameter>
          <parameter>
            <parameterName value="@Logger" />
            <dbType value="String" />
            <size value="100" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%logger" />
            </layout>
          </parameter>
          <parameter>
            <parameterName value="@Message" />
            <dbType value="String" />
            <size value="1000" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%message" />
            </layout>
          </parameter>
          <parameter>
            <parameterName value="@Exception" />
            <dbType value="String" />
            <size value="4000" />
            <layout type="log4net.Layout.ExceptionLayout" />
          </parameter>
        </appender>
        <!-- setup the root category, add the appenders and set the default level -->
    
        <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
          <param name="File" value="Log\后台log.txt" />
          <param name="AppendToFile" value="true" />
          <param name="RollingStyle" value="Date" />
          <param name="DatePattern" value="yyyyMMdd" />
          <param name="StaticLogFileName" value="true" />
    
          <layout type="log4net.Layout.PatternLayout,log4net">
            <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
            <param name="Header" value="-----------------------header--------------------------" />
            <param name="Footer" value="-----------------------footer--------------------------" />
          </layout>
        </appender>
    
        <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
          <layout type="log4net.Layout.PatternLayout">
            <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
          </layout>
        </appender>
        <!-- Setup the root category, add the appenders and set the default level -->
    
    
    
      </log4net>
      <!--Log4net End-->
    </configuration>
  • 相关阅读:
    CentOS6.4 安装OpenResty和Redis 并在Nginx中利用lua简单读取Redis数据
    nginx缓存批量清除
    Centos下Yum安装PHP5.5,5.6
    php中的脚本加速扩展opcache
    Centos 6.5 挂载硬盘 4K对齐 (笔记 实测)
    centos6.5下编译安装FFmpeg
    Python学习九:列表生成式
    Python Select 解析
    Python之基于socket和select模块实现IO多路复用
    Python之路,Day9 , IO多路复用(番外篇)
  • 原文地址:https://www.cnblogs.com/w-ang/p/4974014.html
Copyright © 2020-2023  润新知