I'm using log4cplus library and I can't get logging to work.
I use this code:
PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log.properties"));
Logger g_logger = Logger::getInstance(LOG4CPLUS_TEXT("mylogger"));
LOG4CPLUS_WARN(g_logger, LOG4CPLUS_TEXT("test test test"));
And it breaks at LOG4CPLUS_WARN
with error:
Access violation reading location
This is my Call Stack:
msvcp110d.dll!std::basic_streambuf<wchar_t,std::char_traits<wchar_t> >::egptr() Line 236 C++
ProjectClientd.exe!std::basic_stringbuf<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::str() Line 103 C++
ProjectClientd.exe!std::basic_ostringstream<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::str() Line 553 C++
> ProjectClientd.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 55 C++
ProjectClientd.exe!__tmainCRTStartup() Line 528 C
ProjectClientd.exe!wWinMainCRTStartup() Line 377 C
where wWinMain ... line 55
is a place where LOG4CPLUS_WARN
is being called.
I have checked what's wrong with this basic_ostringstream
and it seems that something is messed up with encoding or something:
Non-terminated string (unreadable memory) and a whole bunch of strange letters at the end of my string? What may cause it?
Have you solved your problem? I have the same error, and I've noticed, that I linked with release version of log4cplusU.dll while application was built in debug, so linkage with log4cplusUD.dll for debug configuration solved my issue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With