Recently I started using Sentry for error logs. I use this snippet to connect:
webBuilder.UseSentry(o =>
{
o.Dsn = settings.GetConnectionString("Sentry"); // env variable
o.AttachStacktrace = true;
o.TracesSampleRate = 1;
o.IncludeActivityData = true;
});
This works fine and it logs errors but I noticed that request payload is not logged. I looked for some tutorials online and found about IncludeRequestPayload = true but in my case it doesn't exist. I use Sentry.AspNetCore version 3.16.0 within a .NET 3.1. Do you know if it's possible to log the payload with this version and if so, how can I do it?
I managed to solve it myself. For anyone that stumbles upon something like this, you just need to add a MaxRequestBodySize to Sentry.Extensibility.RequestSize.Always, although not well described in docs.
webBuilder.UseSentry(o =>
{
o.Dsn = settings.GetConnectionString("Sentry");
o.AttachStacktrace = true;
o.TracesSampleRate = 1;
o.MaxRequestBodySize = Sentry.Extensibility.RequestSize.Always; //this line
o.IncludeActivityData = true;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With