Skip to content

Commit 16eab96

Browse files
Update Readme file.
1 parent e6ec554 commit 16eab96

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,30 @@ or in `appsettings.json` file:
3737

3838
The `WithClientIp()` enricher will add a `ClientIp` property and the `WithClientAgent()` enricher will add a `ClientAgent` property to produced events.
3939

40+
For `ClientIp` enricher you can configure the `X-forwarded-for` header if the proxy server uses a different header to forward IP address.
41+
```csharp
42+
Log.Logger = new LoggerConfiguration()
43+
.Enrich.WithClientIp("CF-Connecting-IP")
44+
...
45+
```
46+
```json
47+
{
48+
"Serilog": {
49+
"MinimumLevel": "Debug",
50+
"Using": [ "Serilog.Enrichers.ClientInfo" ],
51+
"Enrich": [
52+
"WithClientAgent",
53+
{
54+
"Name": "WithClientIp",
55+
"Args": {
56+
"xForwardHeaderName": "CF-Connecting-IP"
57+
}
58+
}
59+
],
60+
}
61+
}
62+
```
63+
4064
## Installing into an ASP.NET Core Web Application
4165
You need to register the `IHttpContextAccessor` singleton so the enrichers have access to the requests `HttpContext` to extract client IP and client agent.
4266
This is what your `Startup` class should contain in order for this enricher to work as expected:
@@ -81,4 +105,4 @@ namespace MyWebApp
81105
}
82106
}
83107
}
84-
```
108+
```

0 commit comments

Comments
 (0)