logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shireesh Thanneru <thann...@yahoo.com>
Subject RE: Wrapping Log4Net with a Facade - How to get the correct Location Information
Date Mon, 29 Aug 2005 04:17:27 GMT

Thanks...That worked like a charm and now I see the actual location

While we are on the facade, I have one more question. For our facade
layer, we will have some configuration information (similat to how
log4net needs its config info) that will configure our facade's
behavior...for e.g. message size limits for each log level, etc. I am
wondering whether we can have this config info in the same file that we
have log4net's configuration (log4net.config in our case) information
and how to get the updated values if this file gets updated. I am
trying to avoid two different config files (one for log4net and one for
our facade), but still be able to configure/bootstrap our facade layer
and reload the updated config info if this file gets updated at run
time. Please let me know what would be a good approach for this.


Shireesh Thanneru

--- Nicko Cadell <nicko@neoworks.com> wrote:

> The log4net ILog / LogImpl types are a façade (also known as wrapper
> or extension) around log4net. If you are creating your own façade you
> need to do the same as the LogImpl class.
> Rather than calling LogManager and wrapping the ILog objects you
> should call into log4net.Core.LoggerManager to get Loggers.
> ILogger logger =
> LoggerManager.GetLogger(Assembly.GetCallingAssembly(), "loggername");
> Then on the logger object use the Log method to inject the logging
> event.
> logger.Log(thisDeclaringType, level, message, exceptionOrNull);
> The thisDeclaringType parameter is the type of your façade object.
> This is used when searching the call stack for the caller location
> information.
> Cheers,
> Nicko
> > -----Original Message-----
> > From: Shireesh Thanneru [mailto:thanneru@yahoo.com] 
> > Sent: 25 August 2005 01:08
> > To: Log4NetUser
> > Subject: Wrapping Log4Net with a Facade - How to get the 
> > correct Location Information
> > 
> > We are wrapping Log4Net with a home grown Facade along the 
> > lines of sl4j. We are doing this basically for two reasons: 
> > to swap the underlying logger (for e.g. replacing log4net 
> > with something else) and to provide additional functionality 
> > at the Facade level (for example, enforcing size limits for 
> > log messages, logging additional info depending on the level, 
> > for e.g COM+ context info, etc). Everything is working fine 
> > so far, but when log4net prints the 
> > loggingEvent.LocationInformation, it is printing the Facade 
> > location/caller information instead of the actual class that 
> > is logging the message. What is the recommended way to solve 
> > this problem and print the correct location information when 
> > we have a wrapper facade on top of log4net?
> > 
> > Thanks,
> > 
> > Shireesh Thanneru
> > 
> > 
> > 	
> > 

View raw message