Is there any .NET logging framework that have ability to switch appender if something is wrong with current one. Actually what I want is following:
If I'm using database appender and when something goes wrong with database (e.g. server goes down, lose power...) I want to switch to second appender (e.g. which log into file).
Does this ability have one of following: log4net, NLog, Enterprise Library? I was looking for this but no luck.
The appender is the part of a logging system that's responsible for sending the log messages to some destination or medium. It answers the question "where do you want to store this stuff?"
Log4j provides Appender objects which are primarily responsible for printing logging messages to different destinations such as console, files, NT event logs, Swing components, JMS, remote UNIX syslog daemons, sockets, etc.
Appenders (also called Handlers in some logging frameworks) are responsible for recording log events to a destination. Appenders use Layouts to format events before sending them to an output.
For completeness: Enterprise Library supports a configurable Error Special Source where you can set an "appender" to log messages that have errored. Once configured this just works without any programming.
The only downside is that it will actually log the exception that occurred along with the Log Entry details in a specific format that cannot be changed so it is not flexible. This is good for troubleshooting but it might not be ideal if you want to extract errored log messages and import them into the original logging destination (although the format is known so it would be possible to parse).
As far as I know log4net currently does not support backup appenders, there is (or was?) an open issue in the log4net feature backlog. But I think that the project called FallbackAppender does exactly what you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With