Tigraine

Daniel Hoelbling-Inzko talks about programming

Log4Net – Logging made easy

Posted by Daniel Hölbling on October 13, 2008

I confess, I’ve done projects that have Console.WriteLine or Debug.Print written all over the place. Sometimes I encapsulated that stuff into a separate Log Class that got passed around to every one, or sometimes I just created this little singleton that did the logging.

Either way, it was code I didn’t really want to write until late in development where I had to go back and retrofit logging into the application. And almost every time I did this it sucked and wasn’t satisfying at all. It worked, but I could have spent countless hours on polishing the logging stuff.

That was until I found Log4Net, the .NET implementation of the open-source log4j framework.

Log4Net enables you to just forget about the logging altogether while you develop your application. Just categorize your log statements into the 5 prioritized levels (DEBUG, INFO, WARN, ERROR, FATAL) and think about the configuration some other day.

Log4Net is completely Xml configuration driven and provides a very high degree of extensibility (Just implement new Appenders, Filters or Layouts).
So it keeps decisions about the where/how/when to log absolutely open until the very end.

Hell, you can even configure a file watcher and change the Log4Net Xml configuration during runtime!

Log4Net has just made it to my imaginary “must reference in each project” list. I strongly suggest you check it out.

comments powered by Disqus

Projects

dynamic css for .NET