When I am writing an application it is so important to make sure you record and log information correctly, there are a number of free loggers you can use
I have come to use NLog, by Jaroslaw Kowalski, it’s so easy to use and get up and running, which is what you really need if you are using a logger of any type.
But what is the best practice when using a log in a live environment?
Or more importantly what and how do you configure you configuration file to make sure you are logging all your information?
The way I see it is, capture your logging to the Event Log and a Database for information and tracing.
When it comes to Errors and Fatal logging then, write it to as many places as you can, an Error file, the Event Log, a Database Log, and perhaps a special Exception Database Log, because if something has failed, you’ll want to shout about it, and you want to record it in as many places as possible.
Here is an example of an NLog configuration
To setup the database use the following creation creation script
Make sure within the SQL Database you have a user “nloguser”, with a password of “nlogpassword”, these are both defined in the NLog configuration file, and can be changed if need be.
That is it, all you have to do now is wait for your live application to log some information.
I am sure there are a few other configuration options available and I welcome anyones comments on how to improve this configuration file.