Replies: 3 comments
-
Do you think this implementation is fine? FileLogger: FileLoggerBackgroundService: LoggerBackgroundService: |
Beta Was this translation helpful? Give feedback.
-
@gumbarros the issue you're referring it to was opened against the old code that has been essentially removed. As of May 2023 this code base is completely different. I'm moving this to a discussion, but you may have better luck finding an answer to your questions in https://github.com/dotnet/runtime or https://github.com/dotnet/aspnetcore repos. |
Beta Was this translation helpful? Give feedback.
-
Moved discussion to dotnet/runtime#87949 |
Beta Was this translation helpful? Give feedback.
-
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:
IHostedService
runs and collects messages from this buffer, flushing them to the I/O sink (remote service, console, file, etc.)Originally posted by @analogrelay in #2141 (comment)
Hello @analogrelay! Can you provide an example? I don't know how to setup a buffer at my ILogger implementation.
Beta Was this translation helpful? Give feedback.
All reactions