Skip to content

Commit bb99749

Browse files
authored
Update README.md
1 parent c1b40f0 commit bb99749

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ or in `appsettings.json` file:
4545

4646
---
4747

48+
### ClientIp
4849
For `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
5051
Log.Logger = new LoggerConfiguration()
@@ -68,7 +69,7 @@ or
6869
}
6970
}
7071
```
71-
72+
### CorrelationId
7273
For `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
@@ -95,12 +96,13 @@ or
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
101103
Log.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
```
106108
or
@@ -135,7 +137,7 @@ or
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
140142
Log.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

Comments
 (0)