logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: Can i have multiple custom appenders loaded in my application? How?
Date Wed, 16 Feb 2005 06:11:34 GMT

On Feb 15, 2005, at 11:44 PM, Kadarkarai, Prabhakar (Prabhakar) wrote:

> Hello All,
>
> I have a custom appender (DLL) which can be used to create and send 
> message to MSMQ.
>
>  I want to use the same appender with different configuration file 
> that means multiple appender scenarios.
>
>  When I tried with multiple appender in configuration file like below 
> it doesn’t work. It loads both appender but creates and sends message 
> to only one MSMQ
>

Hardly enough info to try to analyze the problem.  So both appenders 
are being constructed but only one seems to be working?  Can you set a 
breakpoint at activateOptions?  Are the object's path's different at 
that time?  Are there any static variables in your implementation (if 
path was static it would have the behavior that you are observing)?  Is 
append being called on both appenders, or just one?

>
> When I tried with two different DLL to achieve the results it doesn’t 
> work either. Sample code is below.
>
>  
>
>             HMODULE hModule = LoadLibrary ( "MSMQAppenderDLL.dll" );
>
>             if (hModule==NULL)     return;
>
>             DOMConfigurator::configure(_T("MSMQConfigurationDll.xml"));
>
>             String loggerName = _T("MSMQConfigurationDll");
>
>             LoggerPtr logger = Logger::getLogger(loggerName);
>
>             logger->debug(_T("Custom Client debug message"));
>
>  
>
>             HMODULE shModule = LoadLibrary ( "LIVEMSMQAppenderDLL.dll" 
> );
>
>             if (shModule==NULL)   return;
>
>             
> DOMConfigurator::configure(_T("LIVEMSMQConfigurationDll.xml"));
>
>             String LiveloggerName = _T("LIVEMSMQConfigurationDll");
>
>             LoggerPtr Livelogger = Logger::getLogger(LiveloggerName);
>
>             Livelogger->debug(_T("Live Custom Client debug message"));
>


I'm assuming that your implementation class and registration is 
contained in both DLL's and you've assumed that the second load library 
would trigger a second registration of MSMQAppender which would 
override the entry registered by the first.  I'm pretty sure that there 
are no guarantees on what occurs when you attempt to do that.  
Maintaining the first entry is safer since there may have been 
instances of the first implementation already created and it would 
expect to find the matching class information.


Mime
View raw message