log4net

There are many useful tools on the internet, free for anyone to use. I got very familiar with one called log4net. This tool allows application programmers on the .Net framework to log every little detail in just about any data medium that you can think of.

In the past, I’ve always used the Console to write out information, the Debugger to write out debugging information, and the event log, email, and databases to store error messages. These varied from different applications.

With log4net, you don’t specify the data storage location within the applications compiled code, but rather a configuration file. In the code, you only specify if the message and/or exception to store is debugging information, an information message, a warning message, an error, or a fatal error.

The configuration file is where all the power comes in. You can choose what level of messages should be sent to each storage medium. For console applications, I specify information messages. Warnings, Errors and Fatal messages are logged to the console as well since they are at higher levels then information. I also configured it to send warnings or higher to an administrator through email. There are also methods to save to different types of databases (in my case, I tell it to log everything while in development). The list goes on for all the different places you can save to.

Yesterday I was clueless, today I’m ready to debug the world.

Leave a Reply