You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Http logging with redaction can be enabled by calling <xref:Microsoft.Extensions.DependencyInjection.HttpLoggingServiceCollectionExtensions.AddHttpLoggingRedaction>.
For more information about .NET's data redaction library, see [Data redaction in .NET](data-redaction.md).
217
+
218
+
## Logging redaction options
219
+
220
+
To configure options for logging with redaction, call <xref:Microsoft.Extensions.DependencyInjection.HttpLoggingServiceCollectionExtensions.AddHttpLoggingRedaction> in `Program.cs`, using the lambda to configure <xref:Microsoft.AspNetCore.Diagnostics.Logging.LoggingRedactionOptions>.
Request finished HTTP/2 GET https://localhost:61361/ - 200 - text/plain;+charset=utf-8 105.5334ms
241
+
```
242
+
243
+
> [!NOTE]
244
+
> Request path `/home` is not logged because it is included in `ExcludePathStartsWith` property.
245
+
> `http.request.header.accept` and `http.response.header.content-type` were redacted by the <xref:Microsoft.Extensions.Compliance.Redaction.ErasingRedactor>.
246
+
247
+
### `RequestPathLoggingMode`
248
+
249
+
<xref:Microsoft.AspNetCore.Diagnostics.Logging.LoggingRedactionOptions.RequestPathLoggingMode> determines how the request path is logged, whether `Formatted` or `Structured`.
250
+
251
+
*<xref:Microsoft.AspNetCore.Diagnostics.Logging.IncomingPathLoggingMode.Formatted> logs the request path without parameters.
252
+
*<xref:Microsoft.AspNetCore.Diagnostics.Logging.IncomingPathLoggingMode.Structured> logs the request path with parameters included.
<xref:Microsoft.AspNetCore.Diagnostics.Logging.LoggingRedactionOptions.RequestPathParameterRedactionMode> specifies how route parameters in the request path should be redacted, whether `Strict` or `None`.
259
+
260
+
*<xref:Microsoft.AspNetCore.Diagnostics.Logging.HttpRouteParameterRedactionMode.Strict>: request route parameters are considered as sensitive and are redacted by default.
261
+
* <<xref:Microsoft.AspNetCore.Diagnostics.Logging.HttpRouteParameterRedactionMode.None>: request route parameters are considered as non-sensitive and logged as-is by default.
<xref:Microsoft.AspNetCore.Diagnostics.Logging.LoggingRedactionOptions.RequestHeadersDataClasses> maps request headers to their data classification, which determines how they are redacted.
<xref:Microsoft.AspNetCore.Diagnostics.Logging.LoggingRedactionOptions.ResponseHeadersDataClasses> similar to <xref:responseheadersdataclasses>, but for response headers.
<xref:Microsoft.AspNetCore.Diagnostics.Logging.LoggingRedactionOptions.ExcludePathStartsWith> specifies paths that should be excluded from logging entirely.
0 commit comments