This project is read-only.

Logging exceptions with SqlDatabaseSink

Topics: Using
Sep 24, 2014 at 11:14 AM

I have been using SLAB for quite some time now, and I really like it. For most projects I'm logging to a SQL Server using the SqlDatabaseSink. However when logging exceptions the Payload is often cut off as the serialization of exceptions and their inner exceptions can get pretty big. I log the entire exception like:
try {
   /* do something */
catch (Exception ex)
And of course often with additional context data, etc.

I can see the reason for the truncated Payload is due to:
Has any else been hit by this 4000 limit, and how do you get around it?

I'm considering making a patch to SqlDatabaseSink that allows to override the use of EventEntryDataReader by providing a factory method in the constructor. One can then implement a EventEntryDataReader that does not limit Payload.

Best regards,
Andreas Gehrke
Sep 26, 2014 at 4:30 AM
I haven't encountered this issue but can see that it could cause a problem with large payloads. I don't see any workaround short of changing all the sizes from nvarchar(4000) to nvarchar(max).

Randy Levy
Enterprise Library support engineer
Support How-to