LOG4CXX Common DLL Logging

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

LOG4CXX Common DLL Logging

Hearne, S (Sean)
This is a simplified descriptions of an issue I have with log4cxx logging:
common.dll is used by two executables: prog1.exe and prog2.exe
The executables have separate log files prog1.log and prog2.log
Is it possible to have the logging from common.dll included in the log file of the executable that calls it?
 
Sean
 
 
 


This email (including any attachments to it) is confidential, legally privileged, subject to copyright and is sent for the personal attention of the intended recipient only. If you have received this email in error, please advise us immediately and delete it. You are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. Although we have taken reasonable precautions to ensure no viruses are present in this email, we cannot accept responsibility for any loss or damage arising from the viruses in this email or attachments. We exclude any liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided in this email or its attachments, unless that information is subsequently confirmed in writing.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: LOG4CXX Common DLL Logging

RUOFF, LARS (LARS)
Hi,

I'm not a log4cxx expert at all, but this should work by default.
AFAIK, the code in a DLL is always executed in the process space of the calling process. I.e. two different executables, even though they are using same code from a same DLL will always have their code executed in a completely separate and isolated process environment.
This is not something the log4cxx code has to care about, instead the mechanism is provided by the OS, out-of-the-box.
So for a given log4cxx logger (instantiated in the DLL code), there are actually different logger objects living in the different process environments and will be logging to whatever appender has been specified in their respective environment (by the executable code).

Hope this answers your question.
Regards,
Lars Ruoff


From: Hearne, S (Sean) [mailto:[hidden email]]
Sent: lundi 12 janvier 2015 13:56
To: '[hidden email]'
Subject: LOG4CXX Common DLL Logging

This is a simplified descriptions of an issue I have with log4cxx logging:
common.dll is used by two executables: prog1.exe and prog2.exe
The executables have separate log files prog1.log and prog2.log
Is it possible to have the logging from common.dll included in the log file of the executable that calls it?
 
Sean
 
 
 
________________________________________
This email (including any attachments to it) is confidential, legally privileged, subject to copyright and is sent for the personal attention of the intended recipient only. If you have received this email in error, please advise us immediately and delete it. You are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. Although we have taken reasonable precautions to ensure no viruses are present in this email, we cannot accept responsibility for any loss or damage arising from the viruses in this email or attachments. We exclude any liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided in this email or its attachments, unless that information is subsequently confirmed in writing.
________________________________________
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: LOG4CXX Common DLL Logging

Hearne, S (Sean)
In reply to this post by Hearne, S (Sean)
Hi,

In my exe, I use the following to get the logger:

log4cxx::LoggerPtr Config::logger(log4cxx::Logger::getLogger("MyProg1"));

but as either MyProg1 or MyProg2 can call the dll, how do I get the logger in the dll?

log4cxx::LoggerPtr Config::logger(log4cxx::Logger::getLogger("?????"));

Regards,

Sean

-----Original Message-----
From: Thorsten Schöning [mailto:[hidden email]]
Sent: 12 January 2015 13:41
To: Log4CXX User
Subject: Re: LOG4CXX Common DLL Logging

Guten Tag Hearne, S (Sean),
am Montag, 12. Januar 2015 um 13:55 schrieben Sie:

> Is it possible to have the logging from common.dll included in the log
> file of the executable that calls it?

What's exactly the issue you have now, does it not work or didn't you just try it or whatever? Because from my understanding everything depends on the actual log configuration in use, which loggers are used in the applications/DLL etc. Log4cxx should be usable as a DLL in general, but if your common.dll e.g. uses some hard coded log configuration with loggers you don't know and such, that's the real problem which would have less to do with log4cxx itself.

Mit freundlichen Grüßen,

Thorsten Schöning

--
Thorsten Schöning       E-Mail: [hidden email]
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

--------------------------------------------------------------------------------
This email (including any attachments to it) is confidential, legally privileged, subject to copyright and is sent for the personal attention of the intended recipient only. If you have received this email in error, please advise us immediately and delete it. You are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. Although we have taken reasonable precautions to ensure no viruses are present in this email, we cannot accept responsibility for any loss or damage arising from the viruses in this email or attachments. We exclude any liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided in this email or its attachments, unless that information is subsequently confirmed in writing.
--------------------------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: LOG4CXX Common DLL Logging

Hearne, S (Sean)
Okay, I was coming at the issue from the wrong angle - I had only one config file for all programs.

I'll use a separate one for each exe.

Thanks very much for your help!

Sean

-----Original Message-----
From: Thorsten Schöning [mailto:[hidden email]]
Sent: 12 January 2015 14:35
To: Log4CXX User
Subject: Re: LOG4CXX Common DLL Logging

Guten Tag Hearne, S (Sean),
am Montag, 12. Januar 2015 um 14:45 schrieben Sie:

> but as either MyProg1 or MyProg2 can call the dll, how do I get the logger in the dll?

You don't, in the DLL you normally would work with "CommonDll" or such as logger and in your log4cxx configuration for each application you just configure the logger "CommonDll" to use the same appender and such as MyProg1, MyProg2 and so on. This way you can handle the log statements from the DLL in each application as you like, without the need to know in which application your DLL is used why.

Mit freundlichen Grüßen,

Thorsten Schöning

--
Thorsten Schöning       E-Mail: [hidden email]
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

--------------------------------------------------------------------------------
This email (including any attachments to it) is confidential, legally privileged, subject to copyright and is sent for the personal attention of the intended recipient only. If you have received this email in error, please advise us immediately and delete it. You are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. Although we have taken reasonable precautions to ensure no viruses are present in this email, we cannot accept responsibility for any loss or damage arising from the viruses in this email or attachments. We exclude any liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided in this email or its attachments, unless that information is subsequently confirmed in writing.
--------------------------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: LOG4CXX Common DLL Logging

Hearne, S (Sean)
Thanks. This is working for me now.

One further question, if I have a MyProg3.exe which does not have any reference to Log4cxx but does use the same dll as MyProg1 & 2.

If I check logger->isDebugEnabled() in the dll when called by MyProg3.exe - its showing as true when I didn't configure anything it in the exe. Am I using this function incorrectly?
(in the dll I want to use LOG4XX if configured but do something else if not)


-----Original Message-----
From: Thorsten Schöning [mailto:[hidden email]]
Sent: 12 January 2015 15:40
To: Log4CXX User
Subject: Re: LOG4CXX Common DLL Logging

Guten Tag Hearne, S (Sean),
am Montag, 12. Januar 2015 um 15:59 schrieben Sie:

> I'll use a separate one for each exe.

You don't necessarily need to, because you can still have all your appenders in the same file and some are used during runtime, some not.
But from my point of view it's a good approach to distinct on application level and I would even suggest to follow MS naming schemes like MyProg1.exe.log4cxx.xml, MyProg2.exe.log4cxx.xml and such.

Mit freundlichen Grüßen,

Thorsten Schöning

--
Thorsten Schöning       E-Mail: [hidden email]
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

--------------------------------------------------------------------------------
This email (including any attachments to it) is confidential, legally privileged, subject to copyright and is sent for the personal attention of the intended recipient only. If you have received this email in error, please advise us immediately and delete it. You are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. Although we have taken reasonable precautions to ensure no viruses are present in this email, we cannot accept responsibility for any loss or damage arising from the viruses in this email or attachments. We exclude any liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided in this email or its attachments, unless that information is subsequently confirmed in writing.
--------------------------------------------------------------------------------
Loading...