Best logging library that supports working within "fire and forget" Task code
Does anyone have a recommendation for a logging library that they have personally used and like? Here is what I am looking for:
I have written my application but there are some final nagging bugs. Unfortunately those bugs manifest and cause the application to silently crash only after several days of running. This makes it very inconvenient to debug and I don't want to have an instance of VS running for days at a time just to debug this app. I currently have my own simple bespoke logging code but I think it doesn't handle the scenario where multiple threads/Tasks/etc are trying to log something at the same time even though I have tried to handle this scenario using a lock as follows:
- Needs to work with WPF desktop apps
- Needs to be able to log to the filesystem
- Needs to work with both typical application code AND code that is running as a Task in a "fire and forget" scenario. In other words, I have typical application code that needs to write to a "log.txt" file and then I have several places in that application code that "fire and forget" Tasks and those Tasks also need to write to that same "log.txt" file. By a "fire and forget" Task I mean that I am initiating several different Tasks throughout the code but not "awaiting" their completion. In other words, the Tasks fire asynchronously, there may be several of them running at the same time, and I don't wait for them to complete.
- Easy to use
I have written my application but there are some final nagging bugs. Unfortunately those bugs manifest and cause the application to silently crash only after several days of running. This makes it very inconvenient to debug and I don't want to have an instance of VS running for days at a time just to debug this app. I currently have my own simple bespoke logging code but I think it doesn't handle the scenario where multiple threads/Tasks/etc are trying to log something at the same time even though I have tried to handle this scenario using a lock as follows: