Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Keep Log4Net From Truncating Exceptions?

I'm inserting Log4Net events into a SQL database. The Message and Exception fields are both 8000 characters, but occasionally, an event will come through that is longer than 8000 characters, and the data is getting truncated.

Is there any configurable way to get it to chunk out the events into multiple rows? If not, I'm currently thinking about implementing my own ILog that automatically handles chunking the logging events up so I don't get any truncated data. Does anyone have a better idea?

Edit - Logging Config / Database Column Definition

Here is my current parameter Configuration:

<parameter>
  <parameterName value="@message"/>
  <dbType value="String"/>
  <size value="8000"/>
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%message"/>
  </layout>
</parameter>
<parameter>
  <parameterName value="@exception"/>
  <dbType value="String"/>
  <size value="8000"/>
  <layout type="log4net.Layout.ExceptionLayout"/>
</parameter>

The database tables are defined as such:

[Message] [nvarchar](max) NULL,
[Exeception] [ntext] NULL,
like image 213
Daryl Avatar asked Jul 10 '14 21:07

Daryl


1 Answers

You have to set the size value attribute to -1. This will save the whole exception.

like image 192
Peter Avatar answered Oct 14 '22 08:10

Peter