logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicko Cadell" <ni...@neoworks.com>
Subject RE: Wrapping Log4Net with a Facade - How to get the correct Location Information
Date Thu, 25 Aug 2005 11:51:59 GMT
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.


> -----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