-
Notifications
You must be signed in to change notification settings - Fork 319
Open
Labels
Description
What?
- Too much in
dab startis logged asinformationwhen it should bedebug. - The logging in DAB should be consistent (
informationversusinfo)
Our approach is not standard
Important
We want to be standard!
Our approach
Here's the code where DAB writes out the full enum instead of the abbreviation:
data-api-builder/src/Cli/CustomLoggerProvider.cs
Lines 62 to 77 in 9563a20
| public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter) | |
| { | |
| if (!IsEnabled(logLevel) || logLevel < _minimumLogLevel) | |
| { | |
| return; | |
| } | |
| ConsoleColor originalForeGroundColor = Console.ForegroundColor; | |
| ConsoleColor originalBackGroundColor = Console.BackgroundColor; | |
| Console.ForegroundColor = _logLevelToForeGroundConsoleColorMap[logLevel]; | |
| Console.BackgroundColor = _logLevelToBackGroundConsoleColorMap[logLevel]; | |
| Console.Write($"{logLevel}:"); | |
| Console.ForegroundColor = originalForeGroundColor; | |
| Console.BackgroundColor = originalBackGroundColor; | |
| Console.WriteLine($" {formatter(state, exception)}"); | |
| } |
ASPNETCORE approach
Here's the code where ASPNET writes out the abbreviated enum instead:
https://github.com/dotnet/aspnetcore/blob/f8410f812a2a76401468a78a4f776586c3af498c/src/Components/WebAssembly/WebAssembly/src/Services/WebAssemblyConsoleLogger.cs#L138-L158
Output snippet
C:\Temp\dab-todo-test>dab start -c "dab-config.json" --LogLevel Information
Information: Microsoft.DataApiBuilder 2.0.0
Information: User provided config file: dab-config.json
Information: Loaded config file: dab-config.json
Information: Setting minimum LogLevel: Information.
info: Azure.DataApiBuilder.Service.Startup[0]
Response compression enabled with level 'Optimal' for REST, GraphQL, and MCP endpoints.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[63]
User profile is available. Using 'C:\Users\jnixon\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
info: Azure.DataApiBuilder.Config.FileSystemRuntimeConfigLoader[0]
Loading config file from C:\Temp\dab-todo-test\dab-config.json.
info: Azure.DataApiBuilder.Config.FileSystemRuntimeConfigLoader[0]
Monitoring config: dab-config.json for hot-reloading.
info: Azure.DataApiBuilder.Core.Services.ISqlMetadataProvider[0]
[Todo] REST path: /api//Todo
info: Azure.DataApiBuilder.Service.Startup[0]
Successfully completed runtime initialization.
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\Temp\dab-todo-test
Desired output
ASP.NET Core’s default console formatter shortens some levels. (information -> info) We should do the same because it creates a less chaotic output.
C:\Temp\dab-todo-test>dab start -c "dab-config.json" --LogLevel Information
info: Microsoft.DataApiBuilder 2.0.0
dbug: User provided config file: dab-config.json
dbug: Loaded config file: dab-config.json
dbug: Setting minimum LogLevel: Information.
dbug: Azure.DataApiBuilder.Service.Startup[0]
Response compression enabled with level 'Optimal' for REST, GraphQL, and MCP endpoints.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[63]
User profile is available. Using 'C:\Users\jnixon\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
dbug: Azure.DataApiBuilder.Config.FileSystemRuntimeConfigLoader[0]
Loading config file from C:\Temp\dab-todo-test\dab-config.json.
dbug: Azure.DataApiBuilder.Config.FileSystemRuntimeConfigLoader[0]
Monitoring config: dab-config.json for hot-reloading.
info: Azure.DataApiBuilder.Core.Services.ISqlMetadataProvider[0]
[Todo] REST path: /api//Todo
dbug: Azure.DataApiBuilder.Service.Startup[0]
Successfully completed runtime initialization.
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\Temp\dab-todo-test

Reactions are currently unavailable