Open luuksommers opened 8 months ago
Thanks I also ran into this issue and this helped me get httpContext information
One minor change was that for me the following line in the RawPropertyFactory has to be
return new LogEventProperty(name, new ScalarValue(value));
Thanks I also ran into this issue and this helped me get httpContext information
One minor change was that for me the following line in the RawPropertyFactory has to be
return new LogEventProperty(name, new ScalarValue(value));
You're right, I've updated the original post with your comment.
ECS integration/library project(s): Elastic.CommonSchema.Serilog 8.6.1, Serilog 3.1.1
ECS .NET assembly version (e.g. 1.4.2): 8.6.1
.NET framework / OS: .NET 6 / Windows 11
Description of the problem, including expected versus actual behavior:
Steps to reproduce:
Cause: The
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty(PropertyName, r));
in theHttpContextEnricher
doesn't store the raw object, instead the defaultpropertyFactory
does a.ToString()
of ther
-value, which makes the value of the property:Elastic.CommonSchema.Serilog.HttpContextEnricher,Elastic.CommonSchema.Serilog
instead or the original object. In theLogEventConverter
, the object cannot be retrieved in (for example) theGetUser
methodThis causes that the reported user is always the environment user instead of the user doing the request.
A workaround is to override the enricher: