Fix CLI overrides LogLevel value from config file#3426
Fix CLI overrides LogLevel value from config file#3426RubenCerna2079 wants to merge 9 commits intomainfrom
Conversation
There was a problem hiding this comment.
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
--LogLevelargument injection to only occur whenStartOptions.LogLevelis set. - Improve logging to differentiate whether the log level came from config’s
defaultnamespace vs host-mode fallback. - Add an end-to-end test validating
Startup.IsLogLevelOverriddenByClibehavior with/without the--LogLevelflag.
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. |
Aniruddh25
left a comment
There was a problem hiding this comment.
Needs answers to some questions, and more testing
|
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. |
Aniruddh25
left a comment
There was a problem hiding this comment.
Approving assuming the else part will be removed completely.
I will re-review after this is addressed. Some cases specific to namespace logging testing is also good to add. |
Why make this change?
Whenever we use the
dab startcommand the CLI overrides the minimum LogLevel from the configuration file. This is acceptable only if we use the--LogLevelflag. If we do not use that flag, the LogLevel for each namespace should be decided by the configuration file.What is this change?
This change moves the
args.Addmethods inside theConfigGenerator.csso that they are only applied when we use the--LogLevelflag. 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--LogLevelflag to determine if it was anIsLogLevelOverridenByCliscenario.How was this tested?
Tested with different configurations of the namespaces in the
log-levelproperty 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:
Expected results:
Azure.DataApiBuilder.Core.Services.ISqlMetadataProviderwill provide logs from log level information and above.Azure.DataApiBuilder.Coreand its sub-namespaces that are not fromISqlMetadataProviderwill provide logs from log level debug and above.Azure.DataApiBuilder.Config.FileSystemRuntimeConfigLoaderwill provide logs from log level error and above.Config file includes:
Expected results:
Azure.DataApiBuilder.Coreand its sub-namespaces will provide logs from log level information and above.Azure.DataApiBuilder.Configand its sub-namespaces will provide logs from log level debug and above.host.mode = development, including CLI.Config file includes:
Expected results:
Sample Request(s)
dab start --LogLevel information
dab start (With config file default value debug)