Log4net adds a full stack trace to the database table through the exception parameter

For log4net configuration .. here is my parameter

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

My stored proc in ADONetAppender is installed as follows:

<commandText value="dbo.MyInsertProcName"/>
<commandType value="StoredProcedure"/>

Inside proc, the input parameter for @exception is as follows:

ALTER PROCEDURE [dbo].[MyInsertProcName]        
(    
    @log_date               DATETIME        
    , @log_level            VARCHAR(50)        
    , @logger               VARCHAR(255)        
    , @message              VARCHAR(4000)        
    , @exception            VARCHAR(MAX) 
....

The stored proc procedure writes to the table "MYTable", the length of the column "Exception" as VARCHAR 8000.

I can create an entry in "MYTable", but this entry does not contain the entire trace of the exception stack after creating the entry. It looks like the stack trace is truncated and only contains up to 1700 characters.

What is the best way to register a full stack trace in a database in log4net?

What am I missing?

Please, help.

thank

+2
1

( nvarchar (max)):

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

, , , -1.

+5

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


All Articles