Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sentry not logging request payload in .NET

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?

like image 360
anthino12 Avatar asked Oct 24 '25 04:10

anthino12


1 Answers

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;
});
like image 73
anthino12 Avatar answered Oct 26 '25 18:10

anthino12