Closed smusenok closed 4 months ago
Thanks for reporting the issue. You’re right. For the first time before the middleware sets the IP, the enricher logs the IP and caches the IP address log property in HttpConext
, and it will be used for the rest of the logs in a request. I will fix it.
Could you please review the PR if you have time? https://github.com/serilog-contrib/serilog-enrichers-clientinfo/pull/40 Please keep in mind that always the first client IP log would be "unknown" or "::1" before the middleware sets the IP.
Hello! First of all, thank you for the great enricher!
I tried to handle forwarded headers in the latest version (v2.1.0, net8, win11) using ForwardedHeadersMiddleware and it seems it doesn't work properly. Looks like the updated by ForwardedHeadersMiddleware value of HttpContext.Connection.RemoteIpAddress property is ignored by ClientIpEnricher:
If I send a GET request with X-Forwarded-For: "1.2.3.4" header I can see the following log message:
RemoteIpAddress and XForwardedFor properties contain the expected value "1.2.3.4", but HttpContext.Items["Serilog_ClientIp"] and as the result ClientIp property both have "::1".