log4net AdoNetAppender truncating message text

拥有回忆 提交于 2019-12-24 02:19:06

问题


I have an issue where my message field is being truncated to roughly 42k no matter what I do.

Here's a short snippet to illustrate my configuration:

<log4net>
    <appender name="DbLogs" type="log4net.Appender.AdoNetAppender">
      <connectionType value="..." />
      <bufferSize value="0"/>
      <filter type="log4net.Filter.LevelRangeFilter">
        <levelMin value="INFO" />
      </filter>
      <filter type="log4net.Filter.DenyAllFilter" />
      <connectionString value="Data Source=..." />
      <commandText value="INSERT INTO Logs ([Date],[Thread],[Level],[Logger],[Line],[Location],[Type],[Message],[Exception], [Username], [Guid]) VALUES (@log_date, @thread, @log_level, @logger, @line, @location, @type, @message, @exception, @current_username, @current_guid)" />
      <parameter>
        ...
      </parameter>
      ...
      <parameter>
        <parameterName value="@message" />
        <dbType value="String" />
        <size value="-1" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%message" />
        </layout>
      </parameter>
      ...
    </appender>
    <root>
      <level value="INFO" />
      <appender-ref ref="DbLogs" />
    </root>
  </log4net>

For the message parameter I've tried the size value "-1", "9999999" which made absolutely no difference, it always stores only 42k. 0 rightfully throws an exception.

I also tried removing the size element altogether but that through an exception.

For the dbType I tried AnsiString as well, but had no luck there.

The message field in the Logs table is defined as a varchar(MAX)

Message varchar(MAX)

DB: SQL Server 2012 Log4net: 1.2.11 .net Framework: 4.0

Any ideas?

来源:https://stackoverflow.com/questions/19152349/log4net-adonetappender-truncating-message-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!