Skip to content

Commit 6672f60

Browse files
committed
docs: request response logging
1 parent 1c9a75f commit 6672f60

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

docs/articles/aspnet-core/logging.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ Refine the logs by adding the below to the **appsettings.json**,
105105
}
106106
},
107107
"SeqServerUrl": null,
108-
"WriteToFile" : false
108+
"WriteToFile" : false,
109+
"UseElasticsearchFormatter": false,
109110
}
110111
```
111112

@@ -151,6 +152,32 @@ HTTP "GET" "/hc" responded 200 in 1.3573 ms
151152
----- Handling HTTP Request "http://ordering.api.test.empay.ae/hc" ("")
152153
```
153154

155+
### Request Response Logging Options
156+
157+
#### Include
158+
159+
##### RequestHeaders
160+
161+
Set this to `true` to enable request headers logging. This is disabled by default.
162+
163+
#### Exclude
164+
165+
##### HealthChecks
166+
167+
This will exclude logging for all endpoints with endpoint name "Health checks". This is enabled by default.
168+
169+
##### Paths
170+
171+
No logs for matching paths. Default values are ["/hc", "/liveness"]
172+
173+
##### RequestBody
174+
175+
Request body will not be logged for matching paths
176+
177+
##### ResponseBody
178+
179+
Response body will not be logged for matching paths
180+
154181
## Request logging
155182

156183
Under **Startup.cs** `Configure` method,

src/Code.Library.AspNetCore/Middleware/RequestResponseLogging/ExcludeInRequestResponseLoggingOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ namespace Code.Library.AspNetCore.Middleware.RequestResponseLogging
44
{
55
public class ExcludeInRequestResponseLoggingOptions
66
{
7+
/// <summary>
8+
/// This will exclude logging for all endpoints with endpoint name "Health checks". This is enabled by default.
9+
/// </summary>
710
public bool HealthChecks { get; set; } = true;
811

912
/// <summary>

src/Code.Library.AspNetCore/Middleware/RequestResponseLogging/IncludeInRequestResponseLoggingOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
{
33
public class IncludeInRequestResponseLoggingOptions
44
{
5+
/// <summary>
6+
/// Set this to true to enable request headers logging
7+
/// </summary>
58
public bool RequestHeaders { get; set; } = false;
69
}
710
}

0 commit comments

Comments
 (0)