Clarification on no-async-logging advice (#11843)
parent
9fd3542890
commit
fc3562ef03
|
@ -104,7 +104,7 @@ To write logs in the `Program` class, get an `ILogger` instance from DI:
|
|||
|
||||
### No asynchronous logger methods
|
||||
|
||||
Logging should be so fast that it isn't worth the performance cost of asynchronous code. If your logging data store is slow, don't write to it directly. Consider writing the log messages to a fast store initially, then move them to the slow store later. For example, log to a message queue that's read and persisted to slow storage by another process.
|
||||
Logging should be so fast that it isn't worth the performance cost of asynchronous code. If your logging data store is slow, don't write to it directly. Consider writing the log messages to a fast store initially, then move them to the slow store later. For example, if you're logging to SQL Server, you don't want to do that directly in a `Log` method, since the `Log` methods are synchronous. Instead, synchronously add log messages to an in-memory queue and have a background worker pull the messages out of the queue to do the asynchronous work of pushing data to SQL Server.
|
||||
|
||||
## Configuration
|
||||
|
||||
|
|
Loading…
Reference in New Issue