zoukankan      html  css  js  c++  java
  • asp.net MVC日志插件Log4Net学习笔记二:保存日志到sqlserver的配置

    1.写到sqlserver的配置:

    <!--保存到SQLSERVER数据库日志-->
      <log4net>
        <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
          <!--<bufferSize value="10" />-->
          <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
          <connectionString value="Server=localhost;UID=sa;PWD=8086;DataBase=daohang360;Max Pool Size=1000"/>
          <commandText value="INSERT INTO Log VALUES ([Date],[Thread],[Level],[Logger],[Message],[Exception]) (@log_date, @thread, @log_level, @logger, @message, @exception)" />
          <parameter>
            <parameterName value="@log_date" />
            <dbType value="DateTime" />
            <layout type="log4net.Layout.RawTimeStampLayout" />
          </parameter>
          <parameter>
            <parameterName value="@thread" />
            <dbType value="String" />
            <size value="255" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%thread" />
            </layout>
          </parameter>
          <parameter>
            <parameterName value="@log_level" />
            <dbType value="String" />
            <size value="50" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%level" />
            </layout>
          </parameter>
          <parameter>
            <parameterName value="@logger" />
            <dbType value="String" />
            <size value="255" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%logger" />
            </layout>
          </parameter>
          <parameter>
            <parameterName value="@message" />
            <dbType value="String" />
            <size value="4000" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%message" />
            </layout>
          </parameter>
          <parameter>
            <parameterName value="@exception" />
            <dbType value="String" />
            <size value="2000" />
            <layout type="log4net.Layout.ExceptionLayout" />
          </parameter>
        </appender>
        <root>
          <!-- Set this to "ERROR" before release -->
          <!--Highest: OFF->FATAL->RROR->WARN->INFO->DEBUG->ALL :Lowest -->
          <level value="ALL" />
          <appender-ref ref="AdoNetAppender" />
          <!-- <appender-ref ref="SmtpAppender" /> -->
          <!--<appender-ref ref="FileAppender" /> -->
        </root>
      </log4net>
  • 相关阅读:
    【iOS】The identity used sign the executable is no longer valid.
    【iOS】iOS Error Domain=NSCocoaErrorDomain Code=3840 "未能完成操作。(“Cocoa”错误 3840。)"
    Exponentiation
    A+B Problem
    括号配对
    单调递增最长子序列
    Fibonacci数
    ASCII码排序
    基础练习 数的读法
    基础练习 Sine之舞
  • 原文地址:https://www.cnblogs.com/iack/p/3525104.html
Copyright © 2011-2022 走看看