logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philip Nelson <panmanp...@yahoo.com>
Subject RE: Programatically changing the logger for NHibernate
Date Mon, 28 Nov 2005 14:33:55 GMT


--- Göran Roseen <goran@roseen.se> wrote:

> Philip Nelson wrote: "And, I can use injection techniques to add logging
> setup to my apps with minimal coding."
> 
> This sounds...eh, interesting! Would you care to elaborate on that?

Sure. As I said I was working with HttpRuntime. More specifically, I was
working on an HttpModule and an HttpHandler. So asp.net pages have an error
event you can hook into but the standard way of doing that is to modify
global.asax.cs to override the X_Error methods. You have to repeat this in
every web site. With a handler and module I do this.

module initialise
- app stuff
- initialize log4net
- add an error method for the module that will use the logger

handler
- initialize specific page
- add the error method to the page's onerror event

So that covers asp.net pretty well for top level error logging. The logger is
exposed by a static in my framework so specifically handled logging like debug
calls can take place too. This approach doesn't make much sense for a single
web site, the xml configuration is much easier. But we have many sites that are
identical except for the name of the log file and the subject of the email
message.

I haven't worked this into our windows services yet, but in reality, the
log4net setup and reference to a logger can be done in the same way. The last
step in this will be to explore Castle.DynamicProxy a bit more and then use my
framework like a container. Instances from the container would have logging
available AOP style. But that's just talk on the TODO list at this point.

Philip - http://www.xcskiwinn.org/community/blogs/panmanphil/default.aspx
"Now that was a bad vowel movement" - Barbara

Mime
View raw message