Darrell Norton's Blog [MVP]

Sponsors

The Lounge

Wicked Cool Jobs

News

  • Darrell Norton pic

    MVP logo

    View Darrell Norton's profile on LinkedIn

    Currently Reading:

    weewar.com

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Code of the Month - log4net

This Month’s Code – log4net!

log4net is a tool to help you output log statements to a variety of output targets. log4net is a port of the excellent log4j framework to the .NET runtime. The developers have kept the framework as similar to the original log4j as possible while taking advantage of new features in the .NET runtime.

There are a few interesting things about log4net worth looking at. One is its support for different framework versions across various platforms. The currently supported list is:

  • Microsoft .Net Framework 1.0 (1.0.3705)
  • Microsoft .Net Framework 1.1 (1.1.4322)
  • Microsoft .Net Compact Framework 1.0 (1.0.5000)
  • Mono 0.25 or higher
  • Microsoft Shared Source CLI 1.0

Impressive! Another interesting feature to me is the hierarchical logging architecture which is controllable at runtime. You can get as fine-grained as you want, to the point of being able to turn logging on or off and specify a particular output target for a single class! There are 13 logging targets provided, and log4net is architected for extension, not to mention the ability to customize logging output format! Perhaps most important of all, log4net is exhaustively documented.

One question that comes to mind is how this compares to the Enterprise Instrumentation Framework that Microsoft has put out. Fortunately Daniel Cazzulino has an interesting EIF vs. log4net comparison on his blog.

Look for more to come about log4net as we explore the code this month!

As a refresher, the following is reproduced from last month’s Code of the Month post…

What is the Code of the Month?

The basic idea of the code of the month is to highlight an open source software program. Download it, use it, and read the code. If you’re motivated enough, write an extension to it or fix a bug or two, but the key is to get in there and read the code. Here are a few tips for reading code.

If you blog and want to share your thoughts on the code, just link back to this post. Then everyone can read through your perspective on the code. If you don’t blog or don’t want to write anything up, that’s fine too.

The Benefits

  • Practice reading other people’s code (unless I’m highlighting your program)
  • Exposure to different ways of programming
  • Improvements to your own code!

Posted Tue, Aug 3 2004 9:11 AM by Darrell Norton

[Advertisement]

Comments

Jiho Han wrote re: Code of the Month - log4net
on Tue, Aug 3 2004 6:15 AM
log4net is simply awesome!
I've been using it for a few months now. I was searching for some way to trace in my ASP.NET app but I had difficulties with the built-in Trace class. log4net is so very flexible and did I mention that it's awesome?
By the way, I read Daniel's article too and that's why I decided to go with that. I didn't even check out EIF myself because of it. It just seemed like too much hassle that one. Daniel is also a contributor to log4net project.
Darrell wrote re: Code of the Month - log4net
on Tue, Aug 3 2004 6:51 AM
From what I've seen so far, log4net seems much easier to use. I just wish Daniel Cazzulino would post his WMI appender for log4net!
Jiho Han wrote re: Code of the Month - log4net
on Tue, Aug 3 2004 3:28 PM
Darrell, you should ask him.
He seems like a nice guy from my dealings with him.
Jiho Han wrote User Interface Application Block
on Tue, Aug 3 2004 4:38 PM
User Interface Application Block
nikolai wrote re: Code of the Month - log4net
on Sun, Aug 8 2004 1:30 PM
Just attend Tech Ed and checked out a session on the new version of the Application Blocks, there is a new logging block that has been added to this. I think this is due out in Jan 2005

http://www.gotdotnet.com/community/workspaces/workspace.aspx?ID=295A464A-6072-4E25-94E2-91BE63527327
Darrell wrote re: Code of the Month - log4net
on Mon, Aug 9 2004 4:00 AM
Nikolai - that is correct. The only advantage I see the Logging App Block having is the WMI event sinks. Other than that, I'm leaning more and more toward log4net! :)
Ash wrote Using Apache's log4net in ASP.NET
on Tue, Dec 7 2004 8:57 AM
I have written a simple, seven-step guide that shows how to use Apache's log4net component to add logging capabilities to your ASP.NET applications. It will be very helpful for newbies looking into logging possibilities.
Devlicio.us