Monday, February 19, 2007

Log4Net stopped working - fixed

If you are using log4net, as I am, you may at some point bumped into the same frustration that I endured. I've been using log4X for years, starting with log4j, log4cpp and have used log4net for the past several years, but mostly in standalone .net server apps.

Recently I've started using log4net in a web application, and it worked fine...for awhile. Then it stopped. The problem? I put logging into a classes in a separate project, a projected that encapsulates all my business components and data access layer. Poof! it stopped working. The solution was simple. The AssemblyInfo.cs file in the other project also needed the following line:

[assembly: log4net.Config.XmlConfigurator()]

After putting that in all was well with the world. My UDP collector magically started seeing trace messages and I went about trying to glue back in the hair I'd just violently yanked out. Ah, the life of a developer.

No comments: