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
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:
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.
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.
- 2003/1/16 First made, please comment
- 2003/1/17 Added "The Context" session
- 2003/1/19 Refined the article's structure and content
Major in Object Oriented and Software Engineering.
btw, I am from Taiwan.