serilog-enrichers-aspnetcore-httpcontext
serilog-enrichers-aspnetcore-httpcontext copied to clipboard
Compatibility with Net Core 3.1
The current version doesn't work with .Net Core v3.1. Nothing is parsed in the output.
It seems that the StandardEnricher function is not called from this line _customAction.Invoke(_httpContextAccessor)
in this function but I don't know why:
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
HttpContext ctx = _httpContextAccessor.HttpContext;
if (ctx == null) return;
var httpContextCache = ctx.Items[$"serilog-enrichers-aspnetcore-httpcontext"];
if (httpContextCache == null)
{
httpContextCache = _customAction.Invoke(_httpContextAccessor);
ctx.Items[$"serilog-enrichers-aspnetcore-httpcontext"] = httpContextCache;
}
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("HttpContext", httpContextCache, true));
}
I would love to see this issue addressed, and also the documentation updated around the configuration, since the hostbuilder stuff changed for v3.
I too am unable to get this to work. We need some updated information on how to get this to work with .NET Core 3.1