Log4Net Appender未加载

时间:2011-01-19 18:24:40

标签: log4net log4net-configuration

Log4Net无法加载DB2连接的appender,我看不出原因。它将日志写入文件系统,但是,DB2日志记录没有发生。 Log4Net的版本为v1.2.10.0

<log4net>
  <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
    <bufferSize value="100" />
    <connectionType value="IBM.Data.DB2.DB2Connection,IBM.Data.DB2, Version=8.1.2.1" />
    <connectionString value="server=db2Server;database=dbName;user Id=userId1;password=password;persist security info=true" />
    <commandText value="INSERT INTO GOSDDL.EXCEPTION_LOG (APP_LOG_TS,THREAD,LEVEL,LOGGER,MESSAGE,EXCEPTION) VALUES (@log_date,@thread,@log_level,@logger,@message,@exception)" />
    <parameter>
      <parameterName value="@log_date" />
      <dbType value="DateTime" />
      <layout type="log4net.Layout.RawTimeStampLayout">
        <conversionPattern value="%utcdate" />
      </layout>
    </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>

  <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
    <file value="../logs" />
    <appendToFile value="true"/>
    <maximumFileSize value="512KB"/>
    <maxSizeRollBackups value="2"/>
    <rollingStyle value="Date"/>
    <datePattern value=".yyyy-MM-dd.lo" />
    <staticLogFileName value="false" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%d %l %-2p - %m%n"/>
    </layout>
    <filter type="log4net.Filter.LevelRangeFilter">
      <levelMin value="INFO"/>
      <levelMax value="FATAL"/>
    </filter>
  </appender>

  <root>
    <level value="INFO"/>
    <appender-ref ref="RollingFile"/>
  </root>
</log4net>

1 个答案:

答案 0 :(得分:4)

冒着指出明显的风险,你发布的配置文件实际上并没有使用AdoNetAppender。这是否需要在最后一行用AdoNetAppender替换RollingFile?

如果没有,你可以发布配置文件的其余部分。