Semantic logging - Log to Database

Topics: Semantic Logging Application Block
Mar 11 at 2:55 PM
I have a requirement to check if the log to the database is successful else I have to change the listener to a flat file and log to the flat file.

I have been going through the reference document for Semantic Logging and there it says "The Semantic Logging Application Block uses the error codes listed in the following table to notify you of any problems it encounters at run time."

for eg :
Event Id Level Keywords Description
100 Critical EventListener The DatabaseEventListener class couldn’t open the configured database.

However I have tried writing to a sql server that doesnt exist , and I dont find an exception being thrown. Where will I have to check for these error codes?

Also Can anyone suggest an alternate method to check when the listener fails to log?
Editor
Mar 13 at 1:46 PM
The Semantic Logging Block has its own Sink where errors are logged, SemanticLoggingEventSource. You can enable this event source to see errors:
var semanticListener = new ObservableEventListener();
semanticListener.LogToFlatFile(@"D:\logs\semanticlogging.log");
semanticListener.EnableEvents(SemanticLoggingEventSource.Log, EventLevel.LogAlways, Keywords.All);
If you configure as above then you should be able to see failures (and retries, etc.) but it doesn't address your requirement to log the failed message to a "fallback" sink in the event of a failure. As far as I know this is not currently supported. To get the exact behavior you are looking for I think you would have to write a custom sink that has the specific error handling you want.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Editor
Mar 16 at 7:27 AM
Note that there is a work item for this: http://slab.codeplex.com/workitem/39 .

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to