views:

33

answers:

1

Hello ,

Please help me in the following case. I am using log4net api in my application to log any important event or information as well as logging my exceptions in database.

There might be an exception while using log4net api , if it fails to perform logging into database then HOW THIS EXCEPTION WILL BE STORED? WHERE ALL OTHER LOGGING AND EXCEPTION LOGGING WILL BE STORED IN CASE IF THIS LOG4NET API FAILS TO PERFORM LOGGING ??

Plese help me. I am a final year student of Undergraduate Studies.

Thank you!

A: 

Log4net will fail silently so that the primary function of the application is not disturbed. If you have an event that you absolutely need to have in the database, the you should make it part of your business logic i.e. write it yourself to the database.

If you insist using log4net for this, then you could write an appender that has some fail over logic that makes sure that all events get logged to the database (eventually). However this does not seem to be a good idea...

As for normal logging: In order to ensure that I have logs I usually use a rolling file appender in addition to other appenders. This way I can be quite sure that in the worst case I have the log available in a file.

Stefan Egli