How to save Log4Net from truncating exceptions?

I am inserting Log4Net events into an SQL database. The Message and Exception fields are 8000 characters, but sometimes an event occurs that is longer than 8000 characters and the data is truncated.

Is there any custom way to get it to highlight events on multiple lines? If not, I’m thinking about implementing my own ILog, which automatically handles blocking of registration events, so I don’t get any truncated data. Anyone have a better idea?

Edit - definition of the configuration protocol / database log

Here is my current Configuration parameter:

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

Database tables are defined as such:

[Message] [nvarchar](max) NULL,
[Exeception] [ntext] NULL,
+4
2

-1. .

+3

:

CREATE PROCEDURE [dbo].[Log4net_Insert] 
(
    @Date DATETIME,
    @Thread VARCHAR(255),
    @Level VARCHAR(50),
    @Logger VARCHAR(255),
    @Message VARCHAR(4000),
    @Exception VARCHAR(2000)  /* Set this to MAX to prevent truncation! */
) 
AS

BEGIN

    INSERT INTO [dbo].[Log4Net] 
    ([Date],[Thread],[Level],[Logger],[Message],[Exception]) 
    VALUES (@Date, @Thread, @Level, @Logger, @Message, @Exception)

END

, Microsoft - NTEXT : ntext, text image (Transact-SQL)

! ntext, text SQL Server. , . nvarchar (max), varchar (max) varbinary (max).

0

Source: https://habr.com/ru/post/1547986/


All Articles