Creating a Fail-over for database logging

Topics: Logging Application Block
Feb 19, 2007 at 5:16 PM
Hello. I was wondering if anyone had a good approach for creating a failover for database logging. What I want to do is simply log to a local text file if the database/network is inaccessible.

Feb 19, 2007 at 5:46 PM
I don't know of a way to configure the Logging Application Block to log to a database and only upon failure log to a text file.

You have the option of setting more than one TraceListener to a Category, however, so you could log to both a database and textfile at the same time. If the database fails, you should still have the messages in the text file. When the Rolling Flat File TraceListener is released, you could roll over by file size or time interval in a controlled fashion, which is better than using the FlatFile TraceListener.

The SpecialSources has a LoggingErrors&Warnings Source that is used by the Logging Application Block whenever it has problems logging to a TraceListener. I recommend using that to log and monitor problems that might occur, such as the database not being available.




David Hayden
Microsoft MVP C#