log4net没有保存在ASP.NET中的数据库中

时间:2017-10-23 15:57:41

标签: c# asp.net

我有log4net的问题。在localhost工作正常并保存在数据库(Production1)中,然后在QA中不将日志保存在同一个数据库中(Production1)

的AssemblyInfo.cs

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Web.config", Watch = true)]

的Web.config

<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false" />
  </configSections>
  <!-- Log4Net -->
  <log4net>

    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="wsaopc.log" />
      <appendToFile value="true" />
      <rollingStyle value="Size" />
      <maxSizeRollBackups value="10" />
      <maximumFileSize value="1024KB" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <appender name="debug" type="log4net.Appender.DebugAppender">
      <immediateFlush value="true" />
      <layout type="log4net.Layout.SimpleLayout" />
    </appender>
    <appender name="sql" type="log4net.Appender.AdoNetAppender">
      <bufferSize value="1" />
      <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <connectionStringName value="CSLog4Net" />
      <commandText value="INSERT INTO aopc_sce_ws_log (wslog_fecha, wslog_tarea, wslog_nivel,wslog_logger, wslog_mensaje, wslog_excepcion) VALUES (@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>
    <logger name="WS">
      <level value="ALL" />
      <appender-ref ref="sql" />
      <appender-ref ref="debug" />
      <appender-ref ref="RollingFileAppender" />
    </logger>
    <logger name="EF">
      <level value="ALL" />
      <appender-ref ref="RollingFileAppenderEF" />
    </logger>
    <logger name="BD">
      <level value="ALL" />
      <appender-ref ref="sql" />
    </logger>
  </log4net>     

</configuration>

我在QA中查看并拥有相同的web.config。

0 个答案:

没有答案