File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ Available IP version preferences:
8585- `PreferIpv6 `: Prefer IPv6 addresses when multiple are available , fallback to IPv4
8686- `Ipv4Only `: Only log IPv4 addresses , ignore IPv6 addresses
8787- `Ipv6Only `: Only log IPv6 addresses , ignore IPv4 addresses
88+
8889### CorrelationId
8990For `CorrelationId ` enricher you can :
9091- Configure the header name and default header name is `x -correlation -id `
112113 }
113114}
114115```
116+ #### Retrieving Correlation ID
117+ You can easily retrieve the correlation ID from `HttpContext ` using the `GetCorrelationId ()` extension method :
118+ ```csharp
119+ public void SomeControllerAction ()
120+ {
121+ // This will return the correlation ID that was enriched by the CorrelationIdEnricher
122+ var correlationId = HttpContext .GetCorrelationId ();
123+
124+ if (! string .IsNullOrEmpty (correlationId ))
125+ {
126+ // You can use it for additional logging/tracing, etc
127+ }
128+ }
129+ ```
130+ This eliminates the need for manual casting and provides a clean API for accessing correlation IDs .
131+
115132### RequestHeader
116133You can use multiple `WithRequestHeader ` to log different request headers . `WithRequestHeader ` accepts two parameters ; The first parameter `headerName ` is the header name to log
117134and the second parameter is `propertyName ` which is the log property name .
You can’t perform that action at this time.
0 commit comments