Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fdrumondwoolworths opened this issue Mar 18, 2024 · 3 comments
Open
Labels

Comments

@fdrumondwoolworths
Copy link

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

@nblumhardt
Copy link
Contributor

Hi! You don't happen to be using the Serilog.Exceptions package, by any chance?

@fdrumondwoolworths
Copy link
Author

@nblumhardt hi! I haven't installed this package but I see it's a transitive package in my project.

image

@nblumhardt
Copy link
Contributor

That's the one; however that's being referenced, it'll be configured in your logging pipeline and is responsible for the ExceptionDetail property/data on the resulting events.

@nblumhardt nblumhardt added question and removed bug labels Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants