程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> Log4net記錄日志存庫並存本地,log4net日志庫並存

Log4net記錄日志存庫並存本地,log4net日志庫並存

編輯:C#入門知識

Log4net記錄日志存庫並存本地,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>

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved