@@ -207,22 +207,22 @@ The following list shows the order of precedence for logging configuration:
207
207
208
208
[ !INCLUDE[ ] ( ~/fundamentals/http-logging/includes/index-6-7.md )]
209
209
210
- :::moniker range=">= aspnetcore-10 .0"
210
+ :::moniker range=">= aspnetcore-9 .0"
211
211
212
212
## Redacting sensitive data
213
213
214
214
Http logging with redaction can be enabled by calling ` AddHttpLoggingRedaction ` <!-- Microsoft.Extensions.DependencyInjection.HttpLoggingServiceCollectionExtensions.AddHttpLoggingRedaction> --> :
215
215
216
- [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/8 .x/Program.cs?name=snippet7&highlight=9 )]
216
+ [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/9 .x/Program.cs?name=snippet7&highlight=9 )]
217
217
218
218
For more information about .NET's data redaction library, see [ Data redaction in .NET] ( /dotnet/core/extensions/data-redaction ) .
219
219
220
220
## Logging redaction options
221
221
222
222
To configure options for logging with redaction, call ` AddHttpLoggingRedaction ` <!-- Microsoft.Extensions.DependencyInjection.HttpLoggingServiceCollectionExtensions.AddHttpLoggingRedaction>--> in ` Program.cs ` , using the lambda to configure <!-- Microsoft.AspNetCore.Diagnostics.Logging.LoggingRedactionOptions>--> ` LoggingRedactionOptions ` :
223
223
224
- [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/8 .x/MyTaxonomyClassifications.cs )]
225
- [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/8 .x/Program.cs?name=snippet_redactionOptions&highlight=6 )]
224
+ [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/9 .x/MyTaxonomyClassifications.cs )]
225
+ [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/9 .x/Program.cs?name=snippet_redactionOptions&highlight=6 )]
226
226
227
227
With the previous redaction configuration, the output is similar to the following:
228
228
@@ -254,53 +254,55 @@ info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
254
254
<!-- Microsoft.AspNetCore.Diagnostics.Logging.IncomingPathLoggingMode.Structured> -->
255
255
* ` Structured ` logs the request path with parameters included.
256
256
257
- [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/8 .x/Program.cs?name=snippet_redactionOptions&highlight=9 )]
257
+ [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/9 .x/Program.cs?name=snippet_redactionOptions&highlight=9 )]
258
258
259
259
### RequestPathParameterRedactionMode
260
260
261
261
<!-- Microsoft.AspNetCore.Diagnostics.Logging.LoggingRedactionOptions.RequestPathParameterRedactionMode> -->
262
- ` RequestPathParameterRedactionMode ` specifies how route parameters in the request path should be redacted, whether ` Strict ` or ` None ` .
262
+ ` RequestPathParameterRedactionMode ` specifies how route parameters in the request path should be redacted, whether ` Strict ` , ` Loose ` , or ` None ` .
263
263
264
264
<!-- Microsoft.AspNetCore.Diagnostics.Logging.HttpRouteParameterRedactionMode.Strict>-->
265
- * ` Strict ` : request route parameters are considered as sensitive and are redacted by default.
265
+ * ` Strict ` : Request route parameters are considered sensitive, require explicit annotation with a data classification, and are redacted by default.
266
+ <!-- Microsoft.AspNetCore.Diagnostics.Logging.HttpRouteParameterRedactionMode.Loose>-->
267
+ * ` Loose ` : All parameters are considered as non-sensitive and included as-is by default.
266
268
<!-- Microsoft.AspNetCore.Diagnostics.Logging.HttpRouteParameterRedactionMode.None>-->
267
- * ` None ` : request route parameters are considered as non-sensitive and logged as-is by default .
269
+ * ` None ` : Route parameters aren't redacted regardless of the presence of data classification annotations .
268
270
269
- [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/8 .x/Program.cs?name=snippet_redactionOptions&highlight=8 )]
271
+ [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/9 .x/Program.cs?name=snippet_redactionOptions&highlight=8 )]
270
272
271
273
### RequestHeadersDataClasses
272
274
273
275
<!-- Microsoft.AspNetCore.Diagnostics.Logging.LoggingRedactionOptions.RequestHeadersDataClasses>-->
274
276
` RequestHeadersDataClasses ` maps request headers to their data classification, which determines how they are redacted:
275
277
276
- [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/8 .x/Program.cs?name=snippet_redactionOptions&highlight=10 )]
278
+ [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/9 .x/Program.cs?name=snippet_redactionOptions&highlight=10 )]
277
279
278
280
### ResponseHeadersDataClasses
279
281
280
282
<!-- Microsoft.AspNetCore.Diagnostics.Logging.LoggingRedactionOptions.ResponseHeadersDataClasses>-->
281
283
` ResponseHeadersDataClasses ` , similar to <!-- Microsoft.AspNetCore.Diagnostics.Logging.LoggingRedactionOptions.RequestHeadersDataClasses>--> ` RequestHeadersDataClasses ` , but for response headers:
282
284
283
- [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/8 .x/Program.cs?name=snippet_redactionOptions&highlight=11 )]
285
+ [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/9 .x/Program.cs?name=snippet_redactionOptions&highlight=11 )]
284
286
285
287
### RouteParameterDataClasses
286
288
287
289
<!-- Microsoft.AspNetCore.Diagnostics.Logging.LoggingRedactionOptions.RouteParameterDataClasses>-->
288
290
` RouteParameterDataClasses ` maps route parameters to their data classification:
289
291
290
- [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/8 .x/Program.cs?name=snippet_redactionOptions&highlight=12,13,14,15 )]
292
+ [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/9 .x/Program.cs?name=snippet_redactionOptions&highlight=12,13,14,15 )]
291
293
292
294
### ExcludePathStartsWith
293
295
294
296
<!-- Microsoft.AspNetCore.Diagnostics.Logging.LoggingRedactionOptions.ExcludePathStartsWith>-->
295
297
` ExcludePathStartsWith ` specifies paths that should be excluded from logging entirely:
296
298
297
- [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/8 .x/Program.cs?name=snippet_redactionOptions&highlight=16,17 )]
299
+ [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/9 .x/Program.cs?name=snippet_redactionOptions&highlight=16,17 )]
298
300
299
301
### IncludeUnmatchedRoutes
300
302
301
303
<!-- Microsoft.AspNetCore.Diagnostics.Logging.LoggingRedactionOptions.IncludeUnmatchedRoutes>-->
302
304
` IncludeUnmatchedRoutes ` allows reporting unmatched routes. If set to ` true ` , logs whole path of routes not identified by [ Routing] ( xref:fundamentals/routing ) instead of logging ` Unknown ` value for path attribute:
303
305
304
- [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/8 .x/Program.cs?name=snippet_redactionOptions&highlight=18 )]
306
+ [ !code-csharp[ ] ( ~/fundamentals/http-logging/samples/9 .x/Program.cs?name=snippet_redactionOptions&highlight=18 )]
305
307
306
308
::: moniker-end
0 commit comments