Skip to content

Fix CLI overrides LogLevel value from config file#3426

Open
RubenCerna2079 wants to merge 9 commits intomainfrom
dev/rubencerna/fix-cli-loglevel
Open

Fix CLI overrides LogLevel value from config file#3426
RubenCerna2079 wants to merge 9 commits intomainfrom
dev/rubencerna/fix-cli-loglevel

Conversation

@RubenCerna2079
Copy link
Copy Markdown
Contributor

@RubenCerna2079 RubenCerna2079 commented Apr 10, 2026

Why make this change?

What is this change?

This change moves the args.Add methods inside the ConfigGenerator.cs so that they are only applied when we use the --LogLevel flag. Having these arguments causes DAB to not allow any changes to the LogLevel in the loggers, since those arguments were always being added, DAB always assumed the CLI was overriding the LogLevel when it was not expected as it would use the --LogLevel flag to determine if it was an IsLogLevelOverridenByCli scenario.

How was this tested?

  • Integration Tests
  • Unit Tests
  • Manual Tests
    Tested with different configurations of the namespaces in the log-level property inside the config file.
    Note: ALL these manual tests were tested by running the CLI as well as running DAB through Visual Studio.
    Config file includes:
"log-level": {
    "Azure.DataApiBuilder.Core.Services.ISqlMetadataProvider": "Information",
    "Azure.DataApiBuilder.Core": "Debug",
    "Azure.DataApiBuilder.Config.FileSystemRuntimeConfigLoader": "Error",
    "default": "Warning"
}

Expected results:

  • All the logs from Azure.DataApiBuilder.Core.Services.ISqlMetadataProvider will provide logs from log level information and above.
  • All logs from Azure.DataApiBuilder.Core and its sub-namespaces that are not from ISqlMetadataProvider will provide logs from log level debug and above.
  • All logs from Azure.DataApiBuilder.Config.FileSystemRuntimeConfigLoader will provide logs from log level error and above.
  • Everything else will provide logs from log level warning and above, including CLI.

Config file includes:

"log-level": {
    "Azure.DataApiBuilder.Core": "Information",
    "Azure.DataApiBuilder.Config": "Debug",
}

Expected results:

  • All logs from Azure.DataApiBuilder.Core and its sub-namespaces will provide logs from log level information and above.
  • All logs from Azure.DataApiBuilder.Config and its sub-namespaces will provide logs from log level debug and above.
  • Everything else will provide logs from log level debug and above with host.mode = development, including CLI.

Config file includes:

"log-level": {
    "Default: none
}

Expected results:

  • No logs will be printed, including CLI.

Sample Request(s)

dab start --LogLevel information

dab start (With config file default value debug)

@RubenCerna2079 RubenCerna2079 marked this pull request as ready for review April 13, 2026 20:29
Copilot AI review requested due to automatic review settings April 13, 2026 20:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes dab start so the CLI only overrides the minimum LogLevel when --LogLevel is explicitly provided, allowing config-file log levels to take effect otherwise.

Changes:

  • Move --LogLevel argument injection to only occur when StartOptions.LogLevel is set.
  • Improve logging to differentiate whether the log level came from config’s default namespace vs host-mode fallback.
  • Add an end-to-end test validating Startup.IsLogLevelOverriddenByCli behavior with/without the --LogLevel flag.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/Cli/ConfigGenerator.cs Stops always appending --LogLevel args; adds logic to detect config-provided default log level for logging.
src/Cli.Tests/EndToEndTests.cs Adds an E2E test for CLI log level override behavior by asserting Startup.IsLogLevelOverriddenByCli.

Comment thread src/Cli/ConfigGenerator.cs Outdated
Comment thread src/Cli/ConfigGenerator.cs Outdated
Comment thread src/Cli/ConfigGenerator.cs Outdated
Comment thread src/Cli.Tests/EndToEndTests.cs
Comment thread src/Cli/ConfigGenerator.cs Outdated
Comment thread src/Cli/ConfigGenerator.cs Outdated
Comment thread src/Cli/ConfigGenerator.cs Outdated
Comment thread src/Cli.Tests/EndToEndTests.cs
Comment thread src/Cli/ConfigGenerator.cs Outdated
Copy link
Copy Markdown
Collaborator

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs answers to some questions, and more testing

@github-project-automation github-project-automation bot moved this from Todo to Review In Progress in Data API builder Apr 14, 2026
@anushakolan
Copy link
Copy Markdown
Contributor

Apart from the unit tests, did you manually test it via CLI, if the behavior is as expected. It would be good to have the manual testing section as well in the PR description.

Comment thread src/Cli/ConfigGenerator.cs Outdated
Comment thread src/Cli/ConfigGenerator.cs Outdated
Copy link
Copy Markdown
Collaborator

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving assuming the else part will be removed completely.

@anushakolan
Copy link
Copy Markdown
Contributor

Apart from the unit tests, did you manually test it via CLI, if the behavior is as expected. It would be good to have the manual testing section as well in the PR description.

I will re-review after this is addressed. Some cases specific to namespace logging testing is also good to add.

@RubenCerna2079 RubenCerna2079 enabled auto-merge (squash) April 17, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Review In Progress

Development

Successfully merging this pull request may close these issues.

[Bug]: CLI overrides LogLevel value from config file when it shouldn't

5 participants