Skip to content

Fix LogLevel: CLI phase suppression and case-insensitive "Default" config key#3203

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-loglevel-incorrect-behavior
Draft

Fix LogLevel: CLI phase suppression and case-insensitive "Default" config key#3203
Copilot wants to merge 2 commits intomainfrom
copilot/fix-loglevel-incorrect-behavior

Conversation

Copy link
Contributor

Copilot AI commented Mar 7, 2026

Why make this change?

Two LogLevel bugs: dab start --LogLevel None still emits CLI-phase messages (version, config path, etc.), and using "Default" (capital D) as a key in telemetry.log-level config crashes startup with NotSupportedException.

What is this change?

CLI logger respects --LogLevel

  • CustomConsoleLogger had a hardcoded _minimumLogLevel = LogLevel.Information, making it ignore the --LogLevel flag entirely.
  • Added LogLevel parameter to CustomLoggerProvider / CustomConsoleLogger.
  • Added Program.PreParseLogLevel() — scans raw args[] for --LogLevel before CommandLine.Parser runs — so the logger factory is configured at the right level before any CLI-phase output is emitted.
  • Updated Utils.GetLoggerFactoryForCli(LogLevel) to wire this through.

Case-insensitive "Default" key in config

  • IsLoggerFilterValid used string.Equals (ordinal), so "Default" failed against the registered "default" filter.
  • GetConfiguredLogLevel used TryGetValue("default") (case-sensitive), silently ignoring "Default" keys.
  • Both fixed with StringComparison.OrdinalIgnoreCase / LINQ FirstOrDefault.
// Now works — previously threw NotSupportedException
"telemetry": {
  "log-level": {
    "Default": "warning"
  }
}
# Now silent — previously emitted "Information: Microsoft.DataApiBuilder ..."
dab start --LogLevel None

How was this tested?

  • Integration Tests
  • Unit Tests
    • TestPreParseLogLevel (10 cases): validates pre-parse logic for all levels, numeric forms, =-syntax, and case variants.
    • TestEngineStartUpWithVerboseAndLogLevelOptions: narrowed to Trace/Debug/Information (levels that still produce CLI output).
    • TestEngineStartUpWithHighLogLevelOptions (new): Warning/Error/Critical/None — asserts process starts without checking stdout.
    • ValidStringLogLevelFilters: added "Default" (capital D) data row to cover the case-insensitive validation fix.

Sample Request(s)

# Suppress all output
dab start --LogLevel None

# Config key now case-insensitive
# dab-config.json:
# "telemetry": { "log-level": { "Default": "none" } }
dab start
Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: LogLevel incorrect behavior and failing</issue_title>
<issue_description>## What?

LogLevel isn't working as expected.

Example

This is the normal DAB start output

C:\Temp\dab-todo-test>dab start
Information: Microsoft.DataApiBuilder 1.7.90
Information: Config not provided. Trying to get default config based on DAB_ENVIRONMENT...
Information: Environment variable DAB_ENVIRONMENT is (null)
Loading config file from C:\Temp\dab-todo-test\dab-config.json.
Information: Loaded config file: dab-config.json
Information: Setting default minimum LogLevel: Debug for Development mode.
Starting the runtime engine...
Loading config file from C:\Temp\dab-todo-test\dab-config.json.
Monitoring config: dab-config.json for hot-reloading.
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.Core.Services.ISqlMetadataProvider[0]
      [Todos] REST path: /api/Todos
dbug: Azure.DataApiBuilder.Core.Resolvers.IQueryExecutor[0]
       Executing query: SELECT STE.type_desc FROM sys.triggers ST inner join sys.trigger_events STE On ST.object_id = STE.object_id AND ST.parent_id = object_id(@param0 + '.' + @param1) WHERE ST.is_disabled = 0;
dbug: Azure.DataApiBuilder.Core.Resolvers.IQueryExecutor[0]
       Executing query: SELECT ifsc.COLUMN_NAME from sys.columns as sc INNER JOIN INFORMATION_SCHEMA.COLUMNS as ifsc ON (sc.is_computed = 1 or ifsc.DATA_TYPE = 'timestamp') AND sc.object_id = object_id(@param0+'.'+@param1) AND ifsc.TABLE_SCHEMA = @param0 AND ifsc.TABLE_NAME = @param1 AND ifsc.COLUMN_NAME = sc.name;
dbug: Azure.DataApiBuilder.Core.Services.ISqlMetadataProvider[0]
      Logging primary key information for entity: Todos.
dbug: Azure.DataApiBuilder.Core.Services.ISqlMetadataProvider[0]
      Primary key column name: Id
      Primary key mapped name: Id
      Type: Int32
      IsNullable: False
      IsAutoGenerated: True
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

Suppress ASPNET logging

set Logging__LogLevel__Default=None

This works.

C:\Temp\dab-todo-test>set Logging__LogLevel__Default=None

C:\Temp\dab-todo-test>dab start
Information: Microsoft.DataApiBuilder 1.7.90
Information: Config not provided. Trying to get default config based on DAB_ENVIRONMENT...
Information: Environment variable DAB_ENVIRONMENT is (null)
Loading config file from C:\Temp\dab-todo-test\dab-config.json.
Information: Loaded config file: dab-config.json
Information: Setting default minimum LogLevel: Debug for Development mode.
Starting the runtime engine...
Loading config file from C:\Temp\dab-todo-test\dab-config.json.
Monitoring config: dab-config.json for hot-reloading.
info: Azure.DataApiBuilder.Core.Services.ISqlMetadataProvider[0]
      [Todos] REST path: /api/Todos
dbug: Azure.DataApiBuilder.Core.Resolvers.IQueryExecutor[0]
       Executing query: SELECT STE.type_desc FROM sys.triggers ST inner join sys.trigger_events STE On ST.object_id = STE.object_id AND ST.parent_id = object_id(@param0 + '.' + @param1) WHERE ST.is_disabled = 0;
dbug: Azure.DataApiBuilder.Core.Resolvers.IQueryExecutor[0]
       Executing query: SELECT ifsc.COLUMN_NAME from sys.columns as sc INNER JOIN INFORMATION_SCHEMA.COLUMNS as ifsc ON (sc.is_computed = 1 or ifsc.DATA_TYPE = 'timestamp') AND sc.object_id = object_id(@param0+'.'+@param1) AND ifsc.TABLE_SCHEMA = @param0 AND ifsc.TABLE_NAME = @param1 AND ifsc.COLUMN_NAME = sc.name;
dbug: Azure.DataApiBuilder.Core.Services.ISqlMetadataProvider[0]
      Logging primary key information for entity: Todos.
dbug: Azure.DataApiBuilder.Core.Services.ISqlMetadataProvider[0]
      Primary key column name: Id
      Primary key mapped name: Id
      Type: Int32
      IsNullable: False
      IsAutoGenerated: True
info: Azure.DataApiBuilder.Service.Startup[0]
      Successfully completed runtime initialization.

Suppress DAB Logging at Command Line

dab start --LogLevel None

⭐⭐ This does not work as expected. None should result in ZERO logging. Not a char, except errors.

C:\Temp\dab-todo-test>dab start --LogLevel None
Information: Microsoft.DataApiBuilder 1.7.90
Information: Config not provided. Trying to get default config based on DAB_ENVIRONMENT...
Information: Environment variable DAB_ENVIRONMENT is (null)
Loading config file from C:\Temp\dab-todo-test\dab-config.json.
Information: Loaded config file: dab-config.json
In...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes Azure/data-api-builder#3201

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for you](https://github.com/Azure/data-api-builder/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

…ive Default key

Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix incorrect behavior of LogLevel Fix LogLevel: CLI phase suppression and case-insensitive "Default" config key Mar 7, 2026
@RubenCerna2079 RubenCerna2079 linked an issue Mar 9, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: LogLevel incorrect behavior and failing

2 participants