@@ -45,6 +45,7 @@ or in `appsettings.json` file:
4545
4646---
4747
48+ ### ClientIp
4849For ` ClientIp ` enricher you can configure the ` x-forwarded-for ` header if the proxy server uses a different header to forward the IP address.
4950``` csharp
5051Log .Logger = new LoggerConfiguration ()
6869 }
6970}
7071```
71-
72+ ### CorrelationId
7273For `CorrelationId ` enricher you can :
7374- Configure the header name and default header name is `x -correlation -id `
7475- Set value for correlation id when the header is not available in request header collection and the default value is false
9596 }
9697}
9798```
98-
99- You can use multiple `WithRequestHeader ` to log different request headers .
99+ ### RequestHeader
100+ You can use multiple `WithRequestHeader ` to log different request headers . `WithRequestHeader ` accepts two parameters ; The first parameter `headerName ` is the header name to log
101+ and the second parameter is `propertyName ` which is the log property name .
100102```csharp
101103Log .Logger = new LoggerConfiguration ()
102104 .Enrich .WithRequestHeader (headerName : " header-name-1" )
103- .Enrich .WithRequestHeader (headerName : " header-name-2" )
105+ .Enrich .WithRequestHeader (headerName : " header-name-2" , propertyName : " SomeHeaderName " )
104106 .. .
105107```
106108or
135137```
136138
137139#### Note
138- To include logged headers in `OutputTemplate `, the header name without `- ` should be used . For example , if the header name is `User -Agent `, you should use `UserAgent `.
140+ To include logged headers in `OutputTemplate `, the header name without `- ` should be used if you haven 't set the log property name . For example, if the header name is `User-Agent`, you should use `UserAgent`.
139141```csharp
140142Log .Logger = new LoggerConfiguration ()
141143 .MinimumLevel .Debug ()
@@ -167,7 +169,7 @@ namespace MyWebApp
167169 .Enrich .WithClientIp ()
168170 .Enrich .WithCorrelationId ()
169171 .Enrich .WithRequestHeader (" header-name" )
170- .Enrich .WithRequestHeader (" another-header-name" , " some-property-name " )
172+ .Enrich .WithRequestHeader (" another-header-name" , " SomePropertyName " )
171173 .CreateLogger ();
172174 }
173175
0 commit comments