Skip to content

Exceptions not getting logged in Azure App Insights due its size #223

@fdrumondwoolworths

Description

@fdrumondwoolworths

Description
When using Serilog to log exceptions, the message/event payload is beyond azure app-insights limits and because of that, exceptions don't get logged.

Logging the same exception with a TelemetryClient, in the other hand, logs a message which is comparatively much smaller and gets logged by azure app-insights.

Reproduction
In order to reproduce the problem, I'd have to create a docker with Elastic Search running, create an index and write a query. That would be too much of a hassle for anyone to reproduce the problem.
However, I can provide you with samples of the messages being posted by both TelemetryClient and Serilog, so that you can see that Serilog generates a much longer payload.

Here's a link with the both messages: https://www.diffchecker.com/APhYHCTO/
While the Telemetry logs the exception nicely, the Serilog logs the same exception in a completely different fashion.

The Telemetry ignores the .Request and .Response properties in the ElasticsearchClientException, while Serilog seems to be serializing them as thousands of dictionary keys in the properties list.

BTW, both .Request and .Response in the ElasticsearchClientException are read-only properties, therefore I can't set them to null as a workaround. I've tried Destructurer (IExceptionDestructurer) and Enricher (ILogEventEnricher) but that's didn't help.

Expected behavior
If Serilog wants to serialise .Request and .Response, it shouldn't be that way, right?

Relevant package, tooling and runtime versions
Serilog.Sinks.ApplicationInsights 4.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions