'How can I ensure I am still getting logs with Serilog if MongoDb database is down?
I'm using Serilog to log to MongoDb, but I also use the local Windows Event Logs as a backup store in case there is an issue writing to Mongo. If the setup for MongoDb fails initially, then it falls back to a logger setup that only logs to the Event Logs.
Problem is, the Mongo setup can encounter any number of issues, from a random network blip to the Mongo service itself being down due to full storage. So the setup could fail initially, but I'd like to have my application try again at some interval if the initial Mongo setup failed. Is it possible to do this after the initial logger setup? And is it recommended?
Second, but related question, if the initial setup works, but there is an issue connecting to Mongo at a later time for logging... the app itself hangs (it doesn't appear to crash, as the service still reports as running, but the service stops performing normal functions). Is there a built-in method for handling logging failures in Serilog so that my app doesn't hang? I wouldn't expect that I have to put an exception handler around every single logging request, or IS that the way it's intended to be handled?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
