Skip to content
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

Add logging async method #2141

Closed
EngRajabi opened this issue Aug 6, 2019 · 1 comment
Closed

Add logging async method #2141

EngRajabi opened this issue Aug 6, 2019 · 1 comment

Comments

@EngRajabi
Copy link

EngRajabi commented Aug 6, 2019

Problem

im use sentry logger. sentry Problems with a large number of requests.

Solution

add Ilogger async method. add log to queue and background insert log, like nlogger async warpper.

@analogrelay
Copy link

Making logging async would be very disruptive as it would mean every code path that calls logging would have to be async. It also means that the caller is likely blocked (even if via await) waiting for the log message to be sent.

The recommendation here is to use background worker. This is even what the console logger does (even though it's all in-process). Any logger that does heavy I/O should consider adopting this pattern:

  1. The logger is synchronous and just adds messages to an internal buffer
  2. A background IHostedService runs and collects messages from this buffer, flushing them to the I/O sink (remote service, console, file, etc.)

@ghost ghost added the Status: Resolved label Jan 30, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Mar 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants