问题
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