Skip to content

Fix logs still appearing even when LogLevel is set to none bug#3318

Open
RubenCerna2079 wants to merge 32 commits intomainfrom
dev/rubencerna/fix-loglevel-bugs
Open

Fix logs still appearing even when LogLevel is set to none bug#3318
RubenCerna2079 wants to merge 32 commits intomainfrom
dev/rubencerna/fix-loglevel-bugs

Conversation

@RubenCerna2079
Copy link
Copy Markdown
Contributor

@RubenCerna2079 RubenCerna2079 commented Mar 25, 2026

Why make this change?

What is this change?

Important Note: These changes currently only allow us to change the LogLevel from the CLI with the default namespace in the config file. An task was created to solve this issue: #3451

In order to solve issue #3262:

  • We removed the LogBuffer from the services inside of Startup.cs, this is necessary since we wanted each class to have its own LogBuffer so that we are able to tell from which logger the logs are being outputted.
  • Then, we also correctly initialized the Startup logger by changing the method that it was using to initialize the logger, it now uses CreateLoggerFactoryForHostedAndNonHostedScenario which checks if there are any LogLevel namespaces from the config file that can be applicable for the specific logger. It is important to note that there are multiple places where the logs are flushed in order to cover for the cases in which an exception is found and causes DAB to end abruptly, and when we there is an IsLateConfigured scenario.
  • We also changed the logger for the LogBuffer in all the missing places where it creates logs before the logger is able to properly initialize to add those logs to the LogBuffer and only flush them after the loggers are initialized.

In order to solve issue #3256 & #3255:

  • We changed the CLI so that we add all the logs go to a single global LogBuffer that is created inside the StartOptions.cs until it is able to deserialize the RuntimeConfig and find which level to set the LogLevel in order to flush all the logs.
  • This is something that we only want to happen when we use the dab start command, which is why we only make this change in the StartOptions.cs file, on the function TryStartEngineWithOptions inside of ConfigGenerator.cs, and a few functions from Utils.cs and ConfigMerger.cs that are used inside the TryStartEngine function.

How was this tested?

  • Integration Tests
  • Unit Tests

Sample Request(s)

  • dab start --LogLevel none
  • dab start --LogLevel error

@RubenCerna2079 RubenCerna2079 linked an issue Mar 25, 2026 that may be closed by this pull request
@RubenCerna2079
Copy link
Copy Markdown
Contributor Author

/azp run

@RubenCerna2079 RubenCerna2079 marked this pull request as ready for review March 26, 2026 23:36
Copilot AI review requested due to automatic review settings March 26, 2026 23:36
@RubenCerna2079
Copy link
Copy Markdown
Contributor Author

/azp run

@RubenCerna2079
Copy link
Copy Markdown
Contributor Author

/azp run

@RubenCerna2079 RubenCerna2079 changed the title Fix Setting Azure.DataApiBuilder to none bug Fix logs still appearing even when LogLevel is set to none bug Apr 3, 2026
@Aniruddh25
Copy link
Copy Markdown
Collaborator

For the CLI we first check if the LogBuffer is null, to see if we need to save the log inside the buffer or send directly through the logger, we do this since some of the functions that are used before the loggers are initialized are also used after the logger initialization, so we need a way to ensure that the logs aren't saved after we flush the logger as we are not expecting to use it anymore, which means the logs would be lost.

I do not understand this.

@Aniruddh25
Copy link
Copy Markdown
Collaborator

If we use different LogBuffers for different classes, wouldn't the logs get out of place as we will be flushing the log buffers in a different order of collecting the logs.

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.

Why does the description say we want to fix logs only from dab start? Why not the other commands?

Comment thread src/Cli.Tests/EndToEndTests.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Review In Progress

4 participants