Skip to content

Commit a235748

Browse files
authored
Add missing section.
1 parent c355858 commit a235748

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff 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
8990
For `CorrelationId` enricher you can:
9091
- Configure the header name and default header name is `x-correlation-id`
@@ -112,6 +113,22 @@ or
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
116133
You can use multiple `WithRequestHeader` to log different request headers. `WithRequestHeader` accepts two parameters; The first parameter `headerName` is the header name to log
117134
and the second parameter is `propertyName` which is the log property name.

0 commit comments

Comments
 (0)