You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by "Combes, Chris M." <ch...@ngc.com> on 2004/08/23 22:23:56 UTC

Logging Configuration Across DLL Boundary

Folks,

I have an application which configures my logging system through a ProperyConfigurator. The application instantiates objects which are implemented in external DLLs. When instantiation occurs (e.g. in the constructor of whatever object) the logging configuration is lost. I can get around this by loading the configuration file again within each object, but I should not have to do this.

It looks like whatever log4cxx configuration I use does not carry over across the DLL boundary.

Is this intended behavior? Or is there some special method to get the configuration to carry forward into objets instantiated within a separate DLL?

I'm developing under MSVC++ 6.0.

Any help appreciated.

Thanks,
Chris

Re: Logging Configuration Across DLL Boundary

Posted by Dan Dimerman <di...@netvision.net.il>.
Curt Arnold wrote:
> 
> 
> Could you clarify a few things:
> 
> What version of log4cxx are you using, log4cxx-0.9.7 or the CVS HEAD.  
> There are a lot of things in 0.9.7 that have been fixed in the CVS 
> version (but unfortunately things broken at the current CVS HEAD).  If 
> you can see if the problem still persists with the CVS HEAD that would 
> be helpful.
> 
> Do you have just one executable but it was assembled from object files 
> from multiple static libraries?  Does that executable depend on 
> log4cxx.dll or are you statically linking log4cxx into the executable?
> 
> 

I am using version 0.9.7.

It's just one executable, that is assembled from several static 
libraries. The libraries and the main use log4cxx. There are several 
static variables (LoggerPtr) in those libraries, which causes the 
already known issue of the "null level" assignment to root.
There is no dependence on DLLs whatsoever. I am statically linking 
everything into a single EXE.

thanks


Re: Logging Configuration Across DLL Boundary

Posted by Curt Arnold <ca...@houston.rr.com>.
On Feb 8, 2005, at 4:05 PM, Dan Dimerman wrote:
>
> I have a similar problem with static libraries. I have a bunch of 
> static libs, which all use log4cxx and declare their own logger 
> hierarchy (descendant from the main app's logger).
> Whenever I log from the main app code, it's all good but when I go 
> deep into the static lib code, I get an exception.
> Tracing it, I saw that the problem is in Logger::getEffectiveLevel().
> Looks like it tries to deduce the debugging level when it's not 
> defined for this specific logger. So it goes up to its parent, up till 
> it gets to a logger named "root" which has a null parent pointer.
> Problem is, this root logger is different from the main app root 
> logger: different addresses, different data in the fields, namely the 
> debugging level.
> For the classes in the static libs, their loggers are declared as 
> static. Could this be the problem?
>
> There are no DLLs involved in this situation.
>

Could you clarify a few things:

What version of log4cxx are you using, log4cxx-0.9.7 or the CVS HEAD.  
There are a lot of things in 0.9.7 that have been fixed in the CVS 
version (but unfortunately things broken at the current CVS HEAD).  If 
you can see if the problem still persists with the CVS HEAD that would 
be helpful.

Do you have just one executable but it was assembled from object files 
from multiple static libraries?  Does that executable depend on 
log4cxx.dll or are you statically linking log4cxx into the executable?


Re: Logging Configuration Across DLL Boundary

Posted by Dan Dimerman <di...@netvision.net.il>.
>> Combes, Chris M. wrote:
>>
>>> Folks,
>>> I have an application which configures my logging system through a 
>>> ProperyConfigurator. The application instantiates objects which are 
>>> implemented in external DLLs. When instantiation occurs (e.g. in the 
>>> constructor of whatever object) the logging configuration is lost. /.../
>>> It looks like whatever log4cxx configuration I use does not carry 
>>> over across the DLL boundary.
/../

> 
> That behavior would be expected if the application DLL's were linked 
> with log4cxx static library.  To share logging configurations, the 
> application DLL's must be linked with a log4cxx dynamic library.  There 
> may still be an issue, but please check that you aren't compiling with 
> statically linked log4cxx.

I have a similar problem with static libraries. I have a bunch of static 
libs, which all use log4cxx and declare their own logger hierarchy 
(descendant from the main app's logger).
Whenever I log from the main app code, it's all good but when I go deep 
into the static lib code, I get an exception.
Tracing it, I saw that the problem is in Logger::getEffectiveLevel().
Looks like it tries to deduce the debugging level when it's not defined 
for this specific logger. So it goes up to its parent, up till it gets 
to a logger named "root" which has a null parent pointer.
Problem is, this root logger is different from the main app root logger: 
different addresses, different data in the fields, namely the debugging 
level.
For the classes in the static libs, their loggers are declared as 
static. Could this be the problem?

There are no DLLs involved in this situation.

What am I missing?

Many thanks

Dan


Re: Logging Configuration Across DLL Boundary

Posted by Curt Arnold <ca...@apache.org>.
On Aug 24, 2004, at 4:52 PM, Michaël CATANZARITI wrote:

> Hello,
> Can you be more precise and give code samples, please ?
>
> Regards,
>
> Combes, Chris M. wrote:
>> Folks,
>> I have an application which configures my logging system through a 
>> ProperyConfigurator. The application instantiates objects which are 
>> implemented in external DLLs. When instantiation occurs (e.g. in the 
>> constructor of whatever object) the logging configuration is lost. I 
>> can get around this by loading the configuration file again within 
>> each object, but I should not have to do this.
>> It looks like whatever log4cxx configuration I use does not carry 
>> over across the DLL boundary.
>> Is this intended behavior? Or is there some special method to get the 
>> configuration to carry forward into objets instantiated within a 
>> separate DLL?
>> I'm developing under MSVC++ 6.0.
>> Any help appreciated.
>> Thanks,
>> Chris
>>

That behavior would be expected if the application DLL's were linked 
with log4cxx static library.  To share logging configurations, the 
application DLL's must be linked with a log4cxx dynamic library.  There 
may still be an issue, but please check that you aren't compiling with 
statically linked log4cxx.


Re: Logging Configuration Across DLL Boundary

Posted by Michaël CATANZARITI <mc...@apache.org>.
Hello,
Can you be more precise and give code samples, please ?

Regards,

Combes, Chris M. wrote:
> Folks,
> 
> I have an application which configures my logging system through a ProperyConfigurator. The application instantiates objects which are implemented in external DLLs. When instantiation occurs (e.g. in the constructor of whatever object) the logging configuration is lost. I can get around this by loading the configuration file again within each object, but I should not have to do this.
> 
> It looks like whatever log4cxx configuration I use does not carry over across the DLL boundary.
> 
> Is this intended behavior? Or is there some special method to get the configuration to carry forward into objets instantiated within a separate DLL?
> 
> I'm developing under MSVC++ 6.0.
> 
> Any help appreciated.
> 
> Thanks,
> Chris
> 
> 

-- 
Michaël CATANZARITI
log4cxx project manager

	log4cxx user mailing list:
	mailto:log4cxx-user-subscribe@logging.apache.org

	log4cxx developer mailing list:
	mailto:log4cxx-dev-subscribe@logging.apache.org