Log4net登录数据库

时间:2018-03-21 12:18:22

标签: c# logging log4net

我目前正在使用Log4net登录表,但我需要停止使用该表并将另一个表中的所有内容记录下来以记录错误。基本上我只是更改了log4net值和参数以及我正在记录的表。这是日志文件

<!--SQL LOG TABLE Appender-->
<appender name="LogAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1" />
<!--THIS SETTING ALTERS HOW OFTEN IT WRITES ALL THE LOGGING TO THE DB-->
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<!--local logging connection string-->
<connectionStringName value="DSFDefaultConnection" />
<commandText value="INSERT INTO ProviderHistoryLog ([LogDate],[Event], [CalledPackageName],[ActivityDescription],[SubPackageTaskName],[TaskName]) VALUES (@log_date, @thread, @logger, @message, @notApplicable, @requesturi)" />
<parameter>
  <parameterName value="@ProviderId" />
  <dbType value="long" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="null" />
  </layout>
</parameter>
<parameter>
  <parameterName value="@log_date" />
  <dbType value="DateTime" />
  <layout type="log4net.Layout.RawUtcTimeStampLayout" />
</parameter>
<parameter>
  <parameterName value="@thread" />
  <dbType value="String" />
  <size value="255" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%thread" />
  </layout>
</parameter>
<parameter>
  <parameterName value="@logger" />
  <dbType value="String" />
  <size value="255" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%logger | %class " />
  </layout>
</parameter>
<!--<parameter>
  <parameterName value="@identity" />
  <dbType value="String" />
  <size value="255" />
   <layout type="log4net.Layout.PatternLayout">
    <param name="ConversionPattern" value="DPPAdmin@aez.com"/>-->
    <!-- <converter>-->
      <!-- <name value="httpuser" />-->
       <!-- <type value="fi360.DataServiceFramework.Common.Logging.HttpIdentityUserPatternConverter" />-->
   <!--  </converter>-->
 <!-- </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="@notApplicable" />
  <dbType value="String" />
  <size value="-1" />
  <layout type="%notApplicable" />
</parameter>
<parameter>
  <parameterName value="@requesturi" />
  <dbType value="String" />
  <size value="255" />
  <layout type="log4net.Layout.PatternLayout">
    <param name="ConversionPattern" value="%requesturi"/>
    <converter>
      <name value="requesturi" />
      <type value="fi360.DataServiceFramework.Common.Logging.RequestUriUserPatternConverter" />
    </converter>
  </layout>
  </parameter>
  </appender>

问题是,它没有登录ProviderHistoryLog表。它没有记录任何东西。正如您所看到的,缓冲区大小的值为1,因此我认为问题出在INSERT INTO语句中。

0 个答案:

没有答案