Skip to content

Add log buffering docs #46232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

evgenyfedorov2
Copy link
Member

@evgenyfedorov2 evgenyfedorov2 commented May 16, 2025

@dotnetrepoman dotnetrepoman bot added this to the May 2025 milestone May 16, 2025
@evgenyfedorov2 evgenyfedorov2 force-pushed the users/evgenyfedorov2/log_buffering_doc branch 5 times, most recently from 1ad5e4b to b8fb0b7 Compare May 16, 2025 15:45
@evgenyfedorov2 evgenyfedorov2 force-pushed the users/evgenyfedorov2/log_buffering_doc branch from b8fb0b7 to 5cbf2fc Compare May 16, 2025 16:05
@evgenyfedorov2 evgenyfedorov2 marked this pull request as ready for review May 16, 2025 16:15
@evgenyfedorov2 evgenyfedorov2 requested review from IEvangelist and a team as code owners May 16, 2025 16:15
Copy link
Contributor

@Rageking8 Rageking8 left a comment

Choose a reason for hiding this comment

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

Simple typo and grammatical suggestions.

- Buffers logs from categories starting with `PerRequestLogBufferingFileBased.` with level <xref:Microsoft.Extensions.Logging.LogLevel.Information?displayProperty=nameWithType> and below.
- Sets an auto-flush duration of 5 seconds after manual flushing.

To register the log buffering with the configuration, consider the following code::
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
To register the log buffering with the configuration, consider the following code::
To register the log buffering with the configuration, consider the following code:

> [!NOTE]
> Log buffering is available in .NET 9 and later versions.

Log buffering works with all logging providers. If a logging provider you use does not implement the <xref:Microsoft.Extensions.Logging.Abstractions.IBufferedLogger> interface, log buffering will be calling log methods directly on every single buffered log record when flushing the buffer.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Log buffering works with all logging providers. If a logging provider you use does not implement the <xref:Microsoft.Extensions.Logging.Abstractions.IBufferedLogger> interface, log buffering will be calling log methods directly on every single buffered log record when flushing the buffer.
Log buffering works with all logging providers. If a logging provider you use does not implement the <xref:Microsoft.Extensions.Logging.Abstractions.IBufferedLogger> interface, log buffering will call log methods directly on every single buffered log record when flushing the buffer.


- If the buffer is full, the oldest logs will be dropped and never emitted.
- If you want to emit the buffered logs, you can call `Flush()` on the `GlobalLogBuffer` or `PerRequestLogBuffer` class.
- If you never flush buffers, the buffered logs will eventually be dropped as application runs, so it effectively behaves like those logs are disabled.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- If you never flush buffers, the buffered logs will eventually be dropped as application runs, so it effectively behaves like those logs are disabled.
- If you never flush the buffers, the buffered logs will eventually be dropped as the application runs, so it effectively behaves like those logs are disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[New article]: Log buffering
2 participants