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 "Dalecki, Janusz" <jd...@tycoint.com> on 2018/03/13 23:11:04 UTC

Exception when calling logger->info() method

Hi,
I am having problem with the log4xx throwing an exception while calling logger->info() (it does not happen in Release version). I am using Visual Studio 2017 with the latest log4cxx 0.10.0.
I have logger defined like this:
log4cxx::LoggerPtr LCCService::logger(log4cxx::Logger::getLogger("LCCService"));
.. then I try to log a message like this:
o.str("");
       o << "Initializing LCCService. ConfigPath=" << configFolderPath;
       logger->info(o.str().c_str());
That causes an exception:
[cid:image001.jpg@01D3BB7C.BFFD1750]
... and the stack looks like this:
[cid:image002.jpg@01D3BB7C.BFFD1750]
Can anyone explained that?. I have to admit I have not been actively using C++ for some time.
Regards,
Janusz



________________________________

This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.

RE: Exception when calling logger->info() method

Posted by "Dalecki, Janusz" <jd...@tycoint.com>.
Hi Thorsten,
I have solved the problem. It was my fault. I have compiled the Debug version of my app with NODEBUG micro defined, but Debug version library of log4cxx was correctly defined with the _DEBUG macro defined. After compiling my app with the _DEBUG macro everything is working just fine.
Regards,
Janusz

-----Original Message-----
From: Thorsten Schöning <ts...@am-soft.de>
Sent: Thursday, 15 March 2018 6:14 AM
To: Log4CXX User <lo...@logging.apache.org>
Subject: Re: Exception when calling logger->info() method

Guten Tag Dalecki, Janusz,
am Mittwoch, 14. März 2018 um 04:40 schrieben Sie:

> Thanks for the reply. I have compiled my app and built log4cxx using
> Visual Studio 2017 – so they are coming from the same compiler.

Did you try using the macro as suggested? How did you build log4cxx?
As the access error occurs in Transcoder, it might be worth a try to build using the WCHAR_T-API and only provide Unicode strings as log messages.

Mit freundlichen Grüßen,

Thorsten Schöning

--
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.AM-SoFT.de%2F&data=02%7C01%7Cjdalecki%40tycoint.com%7Cdd16830b63154452db6f08d589dfc2c8%7Ca1f1e2147ded45b681a19e8ae3459641%7C0%7C0%7C636566516499984431&sdata=GibwCpQs4sJryjTVFXqUiINCjqR5JPXB05xalae1S6g%3D&reserved=0

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 e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.

Re: Exception when calling logger->info() method

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Dalecki, Janusz,
am Mittwoch, 14. März 2018 um 04:40 schrieben Sie:

> Thanks for the reply. I have compiled my app and built log4cxx
> using Visual Studio 2017 – so they are coming from the same compiler.

Did you try using the macro as suggested? How did you build log4cxx?
As the access error occurs in Transcoder, it might be worth a try to
build using the WCHAR_T-API and only provide Unicode strings as log
messages.

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: Exception when calling logger->info() method

Posted by "Dalecki, Janusz" <jd...@tycoint.com>.
Hi,
Thanks for the reply. I have compiled my app and built log4cxx using Visual Studio 2017 – so they are coming from the same compiler.
Regards,
Janusz

From: Robert Middleton <os...@gmail.com>
Sent: Wednesday, 14 March 2018 1:27 PM
To: Log4CXX User <lo...@logging.apache.org>
Subject: Re: Exception when calling logger->info() method

Two quick thoughts:


  1.  Have you ensure that the log4cxx dll and your application were compiled with the same version of cl.exe?  MS likes to change ABI compatibility between versions and odd bugs like this can come up when calling across the DLL boundary.
  2.  Is there a reason you aren't using the LOG4CXX_INFO macro?  You should be able to simply use that macro to do what you are trying to do here but in an easier way.  Ex:
LOG4CXX_INFO( logger, "Initializing LCCService. ConfigPath=" << configFolderPath );
I don't know if the second point will do anything, but there could be an issue with your call trying access a temporary variable on the stack.

-Robert Middleton

On Tue, Mar 13, 2018 at 7:11 PM, Dalecki, Janusz <jd...@tycoint.com>> wrote:
Hi,
I am having problem with the log4xx throwing an exception while calling logger->info() (it does not happen in Release version). I am using Visual Studio 2017 with the latest log4cxx 0.10.0.
I have logger defined like this:
log4cxx::LoggerPtr LCCService::logger(log4cxx::Logger::getLogger("LCCService"));
.. then I try to log a message like this:
o.str("");
       o << "Initializing LCCService. ConfigPath=" << configFolderPath;
       logger->info(o.str().c_str());
That causes an exception:
[cid:image001.jpg@01D3BBA2.7001F970]
… and the stack looks like this:
[cid:image002.jpg@01D3BBA2.7001F970]
Can anyone explained that?. I have to admit I have not been actively using C++ for some time.
Regards,
Janusz



________________________________

This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.


________________________________

This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.

Re: Exception when calling logger->info() method

Posted by Robert Middleton <os...@gmail.com>.
Two quick thoughts:


   1. Have you ensure that the log4cxx dll and your application were
   compiled with the same version of cl.exe?  MS likes to change ABI
   compatibility between versions and odd bugs like this can come up when
   calling across the DLL boundary.
   2. Is there a reason you aren't using the LOG4CXX_INFO macro?  You
   should be able to simply use that macro to do what you are trying to do
   here but in an easier way.  Ex:
   LOG4CXX_INFO( logger, "Initializing LCCService. ConfigPath=" <<
   configFolderPath );

I don't know if the second point will do anything, but there could be an
issue with your call trying access a temporary variable on the stack.

-Robert Middleton

On Tue, Mar 13, 2018 at 7:11 PM, Dalecki, Janusz <jd...@tycoint.com>
wrote:

> Hi,
>
> I am having problem with the log4xx throwing an exception while calling
> logger->info() (it does not happen in Release version). I am using Visual
> Studio 2017 with the latest log4cxx 0.10.0.
>
> I have logger defined like this:
>
> *log4cxx::**LoggerPtr* *LCCService**::logger(log4cxx::**Logger*
> *::getLogger(**"LCCService"**));*
>
> .. then I try to log a message like this:
>
> *o.str(**""**);*
>
> *       o **<<* *"Initializing LCCService. ConfigPath="* *<<**
> configFolderPath;*
>
> *       logger**->**info(o.str().c_str());*
>
> That causes an exception:
>
> … and the stack looks like this:
>
> Can anyone explained that?. I have to admit I have not been actively using
> C++ for some time.
>
> Regards,
>
> Janusz
>
>
>
>
>
> ------------------------------
>
> This e-mail contains privileged and confidential information intended for
> the use of the addressees named above. If you are not the intended
> recipient of this e-mail, you are hereby notified that you must not
> disseminate, copy or take any action in respect of any information
> contained in it. If you have received this e-mail in error, please notify
> the sender immediately by e-mail and immediately destroy this e-mail and
> its attachments.
>