Skip to content

Microsoft.Extensions.Logging - Async Logger Example #87949

Answered by davidfowl
gumbarros asked this question in General
Discussion options

You must be logged in to vote
  1. The FileLogger should not capture any arguments from the call to log, it should serialize or copy the data immediately before passing it to the background service.
  2. The buffer needs a maximum size or you'll run out of memory if logging happens too quickly.

https://github.com/JJConsulting/JJMasterData/blob/f639ca2b96d8eadbc9b63215fad4ea4149db04c1/src/Commons/Logging/File/FileLoggerBackgroundService.cs#L82

Consider using System.Text.Json instead of JSON.NET to serialize, did you measure the performance of this?

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by gumbarros
Comment options

You must be logged in to vote
1 reply
@davidfowl
Comment options

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