-
Notifications
You must be signed in to change notification settings - Fork 44
Closed
Labels
Description
Hi
I register the logger like this in my ASP.NET Core app:
services.AddRollbarLogger(loggerOptions =>
{
loggerOptions.Filter = (loggerName, loglevel) => loglevel >= LogLevel.Error;
});
then I want to log via Microsoft.Extensions.Logging. ILogger : ILogger:
logger.LogError(ex, ex.ErrorMessage);
This works fine, except that request body is not being logged. Well, I figured out that HttpRequestPackageDecorator is something I'm looking for.
However I want to leverage ILogger for project specific reasons and don't want to call Rollbar API explicitly like this:
IRollbarPackage rollbarPackage = new ExceptionPackage(ex, $"{nameof(RollbarMiddleware)} processed uncaught exception.");
rollbarPackage = new HttpRequestPackageDecorator(rollbarPackage, this.HttpContext.Request);
RollbarLocator.RollbarInstance.Error(rollbarPackage);
I think the issue is that RollbarHttpContextPackageDecorator (which does not log the request body) is hardcoded in RollbarLogger
protected override IRollbarPackage ComposeRolbarPackage<TState>(
mslogging.EventId eventId,
TState state,
Exception exception,
Func<TState,Exception,string> formatter
)
{
IRollbarPackage package = base.ComposeRolbarPackage(eventId,state,exception,formatter);
var currentContext = GetCurrentContext();
if (currentContext != null)
{
package = new RollbarHttpContextPackageDecorator(package, currentContext, true);
}
return package;
}
Just wondering if there is some workaround to achieve what I want?