Skip to content

Commiting batch of log messages conditionally. #38045

@voroninp

Description

@voroninp

When running in production environment I'd like to have few log messages, if nothing terrible happens.
But in case of failure I need to get all the details and how request was processed.
The problem is that each log entry is independent, and log level is configured on application start.

Describe the solution you'd like

Why not let logger have additional mode of operation?

  1. All messages are grouped in a batch (default "size" = all the messages related to processing single request)
  2. Sending batchade messages works this way:
    • If there are messages with particular log level, then all messages are sent.
    • Otherwise messeges are filtered according to the configured log level.

For example:
I can have as many LogTrace calls as I want in my code, but these messsages won't appear in log unless I call LogError, which is equivalent to dynamically switching to Trace log level in case of error.

This mode can affect performance however, because all messages should be kepr in memory until batch is completed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Extensions-LoggingquestionAnswer questions and provide assistance, not an issue with source code or documentation.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions