Click here to Skip to main content
Click here to Skip to main content

The Pipe Design and Log4Net

, 15 Jan 2004 CPOL
Rate this:
Please Sign up or sign in to vote.
From Designer's view to see the Pipe Architecture and apply with Log4Net

Introduction

The goal of this article is not to show "how to", but from my point of view, one of the reasons why Log4Net looks this way.

After reading this, you could decide to build your own logging engine or to easily use this interesting Framework.

Background You Need

  • An idea about object-oriented programming
  • (Optional) Experience of Log4Net/Log4Net

The Log4Net

You could get this from http://log4net.sourceforge.net/. It's an application framework, focus on the most common event logging service. It's from Java Group. and it's open source. Microsoft has the same Application Framework, try to do this too. It is called "Enterprise Instrumentation Framework (EIF)". When you build a house of application, in addition to the classical tiers solutions, there are some building blocks that can just fit in with any one of those.

For example, the security and the Management as below:

The Abstraction

Image the "sewage treatment". Everyone's house must has pipes, which at the end will be connected into one big "sewage factory". If you ever play the EA's game "SimCity™ 4" you should already know what I am talking about. So, what's interesting? From the above diagram, I had used fish and cancer to explain.

Component: It's your house.

Logger: It's the Pipe with controllable gate door.

Appender: It's the place your pipe will connect to the exact "sewage factory"

Filter: During the flow of pipe, you put kinds of Filter to allow only interesting subjects flow through.

Layout: Once you have got your interesting subject, you need to pack it into Repository Recognizable format.

Render: Finally, you have to physically translate it into the Repository.

We could also think of this in the CRC's way.

The Dynamic View

Our first diagram is another type of collaboration diagram. We could see this in sequence.

Inside the Logger object, when we push event into that Logger, some calculation would look like this:

Writing Motivation and Other Notes

This article is from my point of design view, and I have to say that the trigger for me to write this paper is Log4Net.

It doesn't means that I have read all the papers from them, or I have traced all the source code.

In fact, I had only read their document of Introduction from page 1 to 6, and I want to keep my mind in a creative mode, so I wrote this.

It means, in the real Log4Net project, it sure has more detail or events have a totally different design from what I had imagined.

Since it's a nice hint for me, and that's open source, here I am.

History

  • 2003/1/16 First made, please comment
  • 2003/1/17 Added "The Context" session
  • 2003/1/19 Refined the article's structure and content

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Polo Lee
Web Developer
Taiwan Taiwan
Major in Object Oriented and Software Engineering.
 
btw, I am from Taiwan.
 

Comments and Discussions

 
GeneralMultiple Processes PinsussAnonymous21-Jul-04 20:46 
GeneralRe: Multiple Processes PinmemberPolo Lee23-Jul-04 19:15 
Generalgood article PinmemberSheeba Gandhi19-Apr-04 0:59 
GeneralThe Article Explained PinmemberDave Cantrell21-Jan-04 5:10 
OK, Polo Lee brought up a great subject with Log4NET, but since his English skills are lacking (major applause to you for even trying to learn a new language and communicate with us, by the way) here is what I've gotten from this article.
 
From the web site:
 
"log4net is a tool to help the programmer output log statements to a variety of output targets. log4net is a port of the excellent log4j framework to the .NET runtime."
 
Basically, it works on a basic pipeline architecture, where each component uses and feeds into the components further down the pipe. The main components are the Logger and the Appender. Additional components are Filters, Layouts, and Renderers.
 
LOGGER
* Receives message from your application
* Passes the message on to the Appender
 
APPENDER
* Calls one or more Filters as needed and/or configured, passing the message through the filters for manipulation (removing extraneous data, etc)
* Takes filtered data and calls on the appropriate Layout component to alter the actual representation of the message
OR (not sure which)
* Retrieves the Layout as a template for later merging in the Rendering layer
 
RENDERER
* Either (a) writes the final output to the data store, or (b) receives the message and the layout from the Appender, merges them, then writes the final output to the data store -- depending on how the Appender and Layout component works, I'm not sure
 
Essentially, this approach decouples your production code from the logging mechanics. In other words, if you want to log to a database and a text file, you should be able to write your code to call the Logger component, and not care from the code standpoint how the messages are handled. Then you can configure Log4NET to filter, format, and output the messages to each data store in turn.
 
Hope this helps!
GeneralRe: The Article Explained PinsussAnonymous2-Feb-04 8:50 
GeneralGOOD JOB! PinmemberYih-Cheng Bruce Lee17-Jan-04 4:12 
GeneralRe: GOOD JOB! PinsussAnonymous17-Jan-04 17:42 
GeneralRe: GOOD JOB! PinmemberPolo Lee18-Jan-04 15:22 
GeneralRe: GOOD JOB! PinsussAnonymous19-Jan-04 9:10 
GeneralRe: GOOD JOB! PinmemberPolo Lee19-Jan-04 23:40 
QuestionWow, Ohh, Hmmm??? PinsussAnonymous16-Jan-04 8:48 
AnswerRe: Wow, Ohh, Hmmm??? PinmemberPolo Lee18-Jan-04 15:32 
GeneralRe: Wow, Ohh, Hmmm??? PinsussAnonymous19-Jan-04 9:05 
GeneralRe: Wow, Ohh, Hmmm??? PinmemberPolo Lee19-Jan-04 23:49 
GeneralForget Rose or VisualUML PinmemberOrcrist20-Jan-04 11:06 
GeneralPlease improve this article PinmemberTom Welch16-Jan-04 4:41 
GeneralRe: Please improve this article PinmemberPolo Lee16-Jan-04 15:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411022.1 | Last Updated 16 Jan 2004
Article Copyright 2004 by Polo Lee
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid