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

The Pipe Design and Log4Net

By , 15 Jan 2004
 

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)

About the Author

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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMultiple ProcessessussAnonymous21 Jul '04 - 19:46 
First, NICE WORK!!!
Second, is there a way that multiple processes will write to the same repository (=log file)???
Thanks ahead
GeneralRe: Multiple ProcessesmemberPolo Lee23 Jul '04 - 18:15 
Hi, I dont see there is a problems by your question.
since this is a high level conceptual design.
 
of course it's free in detail design and implementation.
 
software is harder than it sounds
Generalgood articlememberSheeba Gandhi18 Apr '04 - 23:59 
Picture speaks a thousand words.....and ur article proves it.good work...
GeneralThe Article ExplainedmemberDave Cantrell21 Jan '04 - 4: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 ExplainedsussAnonymous2 Feb '04 - 7:50 
When this articel was post, there was NO "explain" for Log4Net.
Who knows what the heck is "Log4Net" until he updated it.....Rose | [Rose]
GeneralGOOD JOB!memberYih-Cheng Bruce Lee17 Jan '04 - 3:12 
Smile | :)
GeneralRe: GOOD JOB!sussAnonymous17 Jan '04 - 16:42 
How good?
He is your brother. Isn't he?Unsure | :~
GeneralRe: GOOD JOB!memberPolo Lee18 Jan '04 - 14:22 
Hi, Mr./Miss noname.
 
I don't have any physical brother who know software here.
unless my parent forgot to tell me so.
 
and thanks for let me know you have no ideal about the design in this article.
 
regards.
 
Polo Lee
 
software is harder than it sounds
GeneralRe: GOOD JOB!sussAnonymous19 Jan '04 - 8:10 

Oh, brother, if I may,
 
You do have sense of humor! I like you (but not your article...)
I really have no idea about this articel!!!
What is "Log4Net"?Rose | [Rose]
GeneralRe: GOOD JOB!memberPolo Lee19 Jan '04 - 22:40 
Hi,
 
I had updated my article 1/19.
did you mean that "the log4Net" session still useless ?
 
or let me try to have another real scenario.
 
when you do the program, you do need to write some debug/trace/manage messages.
and when you ship to your customer. you need to remove those functions.
 
what else ?
image that your customer call in said that the system out of function.
how can you trace what happen ?
you just need another way to log or trace message again.
 
it's easy to keep some log functions by programmer.
but it's not easy to keep the same style in doing that job.
with out the architecture.
if your ap have five Programmer, then you will at the end have five different style tracing or debugging the system.
one is a log file in event log, another one maybe put it in C:\ Drive.
 
and that's way we need the architecture.
that's why .NET Framework provide Trace / Debug Class .
that's why I wrote this abstraction.
 
hope this is useful for you now.
 
currently we are having chinese new year.
and I am having time and also feel fresh to chat here.
 
Happy New Year
 
Polo
 
software is harder than it sounds
QuestionWow, Ohh, Hmmm???sussAnonymous16 Jan '04 - 7:48 
Wow, what a beautiful images.
Ohh, ...... < reading /> ....
Hmmm, what is "pipe", what is "Log4Net"? What is this article trying to say? What is....Rose | [Rose]
 
btw, I am a Taiwanese,too. I did try to understand what are you trying to say... but I just could not figure out...Confused | :confused:
AnswerRe: Wow, Ohh, Hmmm???memberPolo Lee18 Jan '04 - 14:32 
Hi .
 
sorry for confusing you.
and I hope the session I had add could give you some hits.
 
as I mentioned. this article is trying to do something from designer.
so it need some "Abstraction".
 
if you ever see any books that tell ideals from conceptual model to implementation model. then, I am trying to do the conceptual only.
one famous book call "UML Distill, Martin Fowler" had mention this times.
and this is hot sell book even in Taiwan.
 
So far,I can see that I had make too much assumptions.
I had chosen the wrong title, maybe take away the "Log4Net" is better .
 
anyway, thanks for give me the feedback.
 
Polo Lee
 
software is harder than it sounds
GeneralRe: Wow, Ohh, Hmmm???sussAnonymous19 Jan '04 - 8:05 
I have used Rational Rose for X years; UML is big part of our software life-cycle (otherwise, who will spend lofs of $$, time on Ratinal Rose + UML...)
 
However, when I read "pipe", I thought you are talking about "message pipe" or "Mario Brother, the pipeline builder" when you mentioned "Game...".
 
Few years ago, Rational rose + UML was pretty hot in USA. One of my student (I was TA, not prof.) got a job of US$65,000 salary whe he just took "UML" course.... but "UML" market is really going down down down to bottom (IMHO) right now because to use Ratinal Rose (or others apps) + UML really need lots of $$$ and time. I gotta stop complaining....
 
Hope see your article soon.Rose | [Rose]
GeneralRe: Wow, Ohh, Hmmm???memberPolo Lee19 Jan '04 - 22:49 

Hi ,
 
I don't quiet understand the second paragraph you wrote.
 
I do talk about message pipe,
it's everywhere.
 
for example, in ASP.NET,
"Component" is the Page Class, and the "Appender" is the Trace Property it has.
 
more detail in ASP.NET, the HTTP Pipe model is another way that apply this model.
 
too much example for this. and some of them is the message Pipe.
 
---
I know UML/OO had already become what we call ".COM"
too much marketing, isn't .
 
but I do like the OO, no matter how, cause it did change me so much.
 
many thanks for your respecting.
 
Polo Lee
 
software is harder than it sounds
GeneralForget Rose or VisualUMLmemberOrcrist20 Jan '04 - 10:06 
I agree that the $$ for these packages are really detracting from full adoption of UML. Avoid the big boys and look at Enterprise Architect (EA)
 
http://www.sparxsystems.com.au/
 
I subscribe to the software but have no other affiliation with them. It is a full package UML product complete with reverse engineering and it is fairly mature (I've been using it for over 3 years now). Price is < $200US.
I've used both Rose and VisualUML and I prefer EA hands down on a bang for buck basis.
 
They release updates regularly and the updates just require the rerunning of the setup (it will automatically removes the previous version for you) and takes less than 30 sec.
GeneralPlease improve this articlememberTom Welch16 Jan '04 - 3:41 
I was interested in knowing what you were talking about by the article title. After reading the article I am still interested, but I have no clue where to go now. Some example code, a digram of the framework, or a more detailed explanation would go a long way. I understand that english is not your native tongue, but if you could get someone to help clean it up and add to it that would be great.
 


GeneralRe: Please improve this articlememberPolo Lee16 Jan '04 - 14:47 
Hi , thanks for your comments.
 
I had add one more section.
I sure will ponder to make this more nice and friendly.
 
Also, what I think is "Design" itself, really not a easy topic.
Even in my local country, specking with chinese.
there are not many people understand what I want to said.
(that's why I am here)
 
And I do have the experiences to co-work with people in English.
So, I really think, it's not english's problems make all confusing.
 
meanwhile, as My article's subject said.
I don't intent to use source code and how to as first time.
you could get that from Log4Net. or leverage the concept model I made.
 
But maybe I will try add this in the future.
 
regards
 
Polo Lee
 
software is harder than it sounds

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

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