Geeks With Blogs
MeccaN's dev blog A blog about fire-extinguishing real world applications

Today I continued the complete rewrital of our article agent system, the complete rewrital is a necessary step in order to achive the expected number of customers.

The agent system is a non scalable system bought in from another company. But since it was expensive it must be good, right?

This day was dedicated to improve the logging functionality in the new code parts of the application. I wanted the logging to be done by a well tested framework with a simple API.

I started out trying the Microsoft Logging And Instrumentation Application Block. Must give the people at Microsoft credits for the nice administration GUI provided in the enterprise lib. I wanted all parts of the application to write warnings and errors to their corresponding servers eventlog aswell as sending all the logged errors to our customer support mailbox sink.

So I started out defining a general category with 2 destinations.

Destination 1 : Event log destination mapped to an eventlog sink
Destination 2 : Mail log destination mapped to an email sink. 

I copied the generated xml configuration files aswell as the relevant part of app.config in to my test windows application and it all worked flawless. Then i realised that i just wanted the mail log destination to care about errors and just dump the warnings. So I spent some time figuring out how to do this in a nice way. It turned out that there was no nice way (?) and the only solutions i could come up with was

1. Create 2 different categories
2. Use the severity integer to determine whenever to send our not ( atleast i think this one is possible ).

Since none of those 2 strategies where making use of the build in enumeration and both solutions would have required the programmer to use different categories or setting the severity to different values, which isn't straight forward (and our documentation is none existing ;) ), I chosed not to go with any of them. I also noticed that the logging and instrumentation block was writing errors regarding performance counter in my eventlog, the solution to this problem was apperently to run installutil.exe on all enterprise library assemblies on all the destination servers, which I personally think is stupid and frustrating. 

Then i decided to try out log4net

After had spending a short amount of time reading the documentation about log4net i decided that i just wanted to go with the root log and use the appenders for the eventlog and for the mailing. (Since i was using the root log i didn't have to specify any log name for the LogManager.GetLog method)
Log4net had support for setting event types (info, warn, error etc...) on the appenders but i didn't really liked the API as much as i liked the logging and instrumentation block so I was faced with a hard decision

I ended up running log4net and the primary reasons for taking this decision was:

  • The system is build on top of nHibernate, nHibernate uses log4net.
  • I didn't really liked the missing possibility of setting log event types on the destinations in the log & inst block. And i didn't came up with any graceful work around for this (expect writing my own sinks or something like that).
  •  The in my opinion somewhat ugly log4net API I could easily get away from by creating my own wrapper.
  • The extra effort of running installutil on every used assembly in the application block ( in this case the configuration block asm and the logging block asm ).

If anybody has any tips or knows something that i don't about the logging and instrumentation block. Feel free to drop comments =)

 

Posted on Monday, January 16, 2006 5:02 PM | Back to top


Comments on this post: Monday

# re: Monday
Requesting Gravatar...
Are you using the Exception Handling Block too? I use it to trap different errors into separate log files. This might be a work-around for creating different log event types.
Left by Brian on Jan 20, 2006 12:13 PM

# re: Monday
Requesting Gravatar...
Nah. Haven't tried the Exception Handling Block at all. I will have to check it out this week.
Thanks.
Left by Marcus F on Jan 22, 2006 5:32 PM

Your comment:
 (will show your gravatar)


Copyright © Marcus F | Powered by: GeeksWithBlogs.net