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 Oscar Pernas <os...@pernas.es> on 2012/10/24 16:14:15 UTC

multiples instances of log4cxx

Hi all,

I have a DLL (with vs2008) that uses log4cxx. All is working ok
reading configuration file log4AI.properties.

I have a process that loads this DLL and uses log4cxx too. This
process is configured to read a properties file log4jSM.properties.
When the process starts, the firsts traces are correctly logged into
the correct file (log4SM.txt).

After the process loads the DLL, all traces in the process are not
going to the correct file and all goes to the logAI.txt (using
log4AI.properties).

Is log4cxx a singleton? could I have different instances of log4cxx in
the same process?


Regards

-- 
Óscar Pernas Plaza.

Re: multiples instances of log4cxx

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Oscar Pernas,
am Mittwoch, 23. Januar 2013 um 13:29 schrieben Sie:

> What I'm doing wrong? I think that Im linking with the correct dinamic library...

Did you read my quoted link? The behavior you see is intended on
dynamic link libraries.

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail:Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


Re: multiples instances of log4cxx

Posted by Oscar Pernas <os...@pernas.es>.
Hi Thorsten,

I was looking into this problem again:

My process is call MyAI. MyAi is loading its instance of log4cxx like this:

static log4cxx::LoggerPtr loggerMyAI;
LoggerPtr MyAI::loggerMyAI(Logger::getLogger("MyAI"));
PropertyConfigurator::configure("log4jMyAI.properties");

After this configure method, The first trace is sent using
log4MyAI.properties correctly.



After that, the process loads a dll that uses log4cxx in the same way the
process.

static log4cxx::LoggerPtr logger;
LoggerPtr AI::logger(Logger::getLogger("AI"));
PropertyConfigurator::configure("log4jAI.properties");

And after that, all traces (process and dll's) are sent using
log4jAI.properties.


I was looking how the process is loading log4cxx library with ldd and I
think that is using it dinamically (correct me if Im wrong):

(PROCESS)

ldd ActiveInterfaceTest
        liblog4cxx.so.10 => /usr/lib/liblog4cxx.so.10 (0x00007f813ed09000)



(DLL) ldd libAI.so
        liblog4cxx.so.10 => /usr/lib/liblog4cxx.so.10 (0x00007fb53683a000)


What I'm doing wrong? I think that Im linking with the correct dinamic
library...


Regards


2013/1/17 Oscar Pernas <os...@pernas.es>

> Hi Thorsten,
>
> I was looking into this problem again:
>
> My process is call MyAI. MyAi is loading its instance of log4cxx like this:
>
> static log4cxx::LoggerPtr loggerMyAI;
> LoggerPtr MyAI::loggerMyAI(Logger::getLogger("MyAI"));
> PropertyConfigurator::configure("log4jMyAI.properties");
>
> After this configure method, The first trace is sent using
> log4MyAI.properties correctly.
>
>
>
> After that, the process loads a dll that uses log4cxx in the same way the
> process.
>
> static log4cxx::LoggerPtr logger;
> LoggerPtr AI::logger(Logger::getLogger("AI"));
> PropertyConfigurator::configure("log4jAI.properties");
>
> And after that, all traces (process and dll's) are sent using
> log4jAI.properties.
>
>
> I was looking how the process is loading log4cxx library with ldd and I
> think that is using it dinamically (correct me if Im wrong):
>
> (PROCESS)
>
> ldd ActiveInterfaceTest
>         liblog4cxx.so.10 => /usr/lib/liblog4cxx.so.10 (0x00007f813ed09000)
>
>
>
> (DLL) ldd libAI.so
>         liblog4cxx.so.10 => /usr/lib/liblog4cxx.so.10 (0x00007fb53683a000)
>
>
> What I'm doing wrong? I think that Im linking with the correct dinamic
> library...
>
>
> Regards
>
>
> 2012/10/24 Thorsten Schöning <ts...@am-soft.de>
>
>> Guten Tag Oscar Pernas,
>> am Mittwoch, 24. Oktober 2012 um 16:14 schrieben Sie:
>>
>> > Is log4cxx a singleton? could I have different instances of log4cxx in
>> > the same process?
>>
>> This should answer your question with no on dynamic linking like yours.
>>
>>
>> http://mail-archives.apache.org/mod_mbox/logging-log4cxx-user/200408.mbox/%3C856DBBCE-F622-11D8-B017-000393B97126@apache.org%3E
>>
>> Mit freundlichen Grüßen,
>>
>> Thorsten Schöning
>>
>> --
>> Thorsten Schöning       E-Mail:Thorsten.Schoening@AM-SoFT.de
>> AM-SoFT IT-Systeme      http://www.AM-SoFT.de/
>>
>> Telefon...........05151-  9468- 55
>> Fax...............05151-  9468- 88
>> Mobil..............0178-8 9468- 04
>>
>> AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
>> AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow
>>
>>
>
>
> --
> Óscar Pernas Plaza.
>



-- 
Óscar Pernas Plaza.

Re: multiples instances of log4cxx

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Oscar Pernas,
am Mittwoch, 24. Oktober 2012 um 16:14 schrieben Sie:

> Is log4cxx a singleton? could I have different instances of log4cxx in
> the same process?

This should answer your question with no on dynamic linking like yours.

http://mail-archives.apache.org/mod_mbox/logging-log4cxx-user/200408.mbox/%3C856DBBCE-F622-11D8-B017-000393B97126@apache.org%3E

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail:Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow