Can any one let me know how to implement logging with Enterprise Library 6.0 in C#. I want to do logging in Database, if it is available otherwise log the exceptions , information, messages into LOG file.
Can anyone tell me How to implement logging into Db, otherwise log in file dynamically.
I will have both logging DB and file config changes in App.config
/Web.config
.
So please help me on this how to implement logging dynamically based on runtime value:
If Db is available and accessible, then log, otherwise if DB is not accessible, then log to Log-file or event-viewer.
Asked
Active
Viewed 1,144 times
0

Lorenz Lo Sauer
- 23,698
- 16
- 85
- 87

user145610
- 2,949
- 4
- 43
- 75
1 Answers
0
The new version 6 makes comprehensive use of the factory pattern, hence you need to set the logger up differently in version 6:
Try the following:
IConfigurationSource configsrc = ConfigurationSourceFactory.Create(); LogWriterFactory logWriterFactory = new LogWriterFactory(configsrc); Logger.SetLogWriter(logWriterFactory.Create()); Logger.Write("logtest", "General");
Your description of your database logging requirements isn't quite clear, but I think these Code examples and links should be what you are looking for.

Lorenz Lo Sauer
- 23,698
- 16
- 85
- 87
-
Hi Lo, Thanks for answering the question, Basically i will have functionality of logging in File and Database same. Only change, is if the database is available, log the errors, exceptions & warning into database , if it not available log the details into File. – user145610 Sep 05 '13 at 07:10