serilog-contrib / serilog-enrichers-clientinfo

Enrich logs with client IP, correlation id and HTTP request headers.
MIT License
93 stars 20 forks source link

Make ip header variable configurable? #11

Closed zyofeng closed 2 years ago

zyofeng commented 2 years ago

Currently this lib uses X-forwarded-for to get client ip, however in some proxy environments i.e. Cloudflare. Ips are piped through custom http headers (CF-Connecting-IP) https://developers.cloudflare.com/fundamentals/get-started/reference/http-request-headers/

Would it be possible to make this header variable name configurable with defaults to X-forwarded-for?

Regards

mo-esmp commented 2 years ago

It's possible, however, need to figure out how to set the configuration for enricher in appsettings.json file.

nblumhardt commented 2 years ago

It's the same syntax as WriteTo; there isn't a lot of documentation, but the Serilog.Settings.Configuration sample project has a pretty complete example:

https://github.com/serilog/serilog-settings-configuration/blob/dev/sample/Sample/appsettings.json#L66

HTH, Nick

mo-esmp commented 2 years ago

@zyofeng Sorry for the delay, please update to version 1.2.0.

zyofeng commented 2 years ago

No worries, thank you!