Update Blazor auth logging 7.0 (#27176)

pull/27168/head
Luke Latham 2022-10-03 11:37:23 -05:00 committed by GitHub
parent 46bfe4a158
commit 297d86c564
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 26 deletions

View File

@ -1749,35 +1749,20 @@ var connection = new HubConnectionBuilder()
*This section only applies to Blazor WebAssembly apps.*
Log messages specific to <xref:Microsoft.AspNetCore.Components.WebAssembly.Authentication?displayProperty=fullName> for the <xref:Microsoft.Extensions.Logging.LogLevel.Debug?displayProperty=nameWithType> or <xref:Microsoft.Extensions.Logging.LogLevel.Trace?displayProperty=nameWithType> logging levels using ***either*** the following approaches:
Log Blazor authentication messages at the <xref:Microsoft.Extensions.Logging.LogLevel.Debug?displayProperty=nameWithType> or <xref:Microsoft.Extensions.Logging.LogLevel.Trace?displayProperty=nameWithType> logging levels with a log filter for <xref:Microsoft.AspNetCore.Components.WebAssembly.Authentication?displayProperty=fullName> in `Program.cs`.
* Add a log filter for <xref:Microsoft.AspNetCore.Components.WebAssembly.Authentication?displayProperty=fullName> in `Program.cs`:
The following example:
```csharp
#if DEBUG
builder.Logging.AddFilter(
"Microsoft.AspNetCore.Components.WebAssembly.Authentication",
LogLevel.Debug);
#endif
```
* Activates logging for the `Debug` build configuration using a [C# preprocessor directive](/dotnet/csharp/language-reference/preprocessor-directives).
* Logs Blazor authentication messages at the <xref:Microsoft.Extensions.Logging.LogLevel.Debug> log level.
* Provide an app settings file for the `Development` environment (`wwwroot/appsettings.Development.json`) with log level configuration:
```json
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"Microsoft.AspNetCore.Components.WebAssembly.Authentication": "Debug"
}
}
}
```
Set the value to either "`Debug`" or "`Trace`".
```csharp
#if DEBUG
builder.Logging.AddFilter(
"Microsoft.AspNetCore.Components.WebAssembly.Authentication",
LogLevel.Debug);
#endif
```
> [!NOTE]
> Blazor WebAssembly apps only log to the client-side [browser developer tools](https://developer.mozilla.org/docs/Glossary/Developer_Tools) console.