Reputation: 498
I am using Enterprise library 5.0 for Logging mechanism. I am using flat file and DB listeners. I want to make sure that the errors were logged into the db and in case some error occurred while doing the same the error should automatically start logging into the flat files. I guess we need to switch to Flat file Logging automatically in case of an exception.
loggingConfiguration name="Logging" tracingEnabled="true" defaultCategory="DatabaseLogging"
But I believe the defaultCateogory
is a read only property for the section. How I can do it programatically?
Upvotes: 1
Views: 2428
Reputation: 2019
You may consider to use Unit test, to make sure the will log the errors in all different scenario , thats why we have unit test :)
Unit testing is all about automation, so you need to be able to automate the validation of log entries.
also you can consider using Priority. (it is used to filter Log Entries, only those above the “Minimum Priority” are processed), so it something has high priority , it may go to the flat file as well.
Hope it will help.
Upvotes: 1
Reputation: 2368
There is a special category called Logging Errors & Warnings which you should hook up to a listener to be notified when your normal logging category fails. You should also put the listeners on your normal category in order from most likely to work to most likely to fail, because writing to the listeners will stop once there is a failure.
Also, default category is not read only. That is the category that logs will be written to if you do not specify a category when creating a log entry. Logging errors will not be written to that category however. Those only go to the Logging Errors & Warnings special category.
Upvotes: 0