log4qt icon indicating copy to clipboard operation
log4qt copied to clipboard

log4qttest ends with 8 failed tests and segfault

Open joede opened this issue 9 years ago • 7 comments

I've tried to find a loggin library for Qt5 and found this port of Log4Qt. This was the first library that I was able to compile, but the test application fails. I'm running Debian 8 with Qt 5.3.

The output of the test can be found here: https://gist.github.com/joede/2157b3895ab52354bb6cbec383f8817e

joede avatar Jul 25 '16 06:07 joede

Hi Joede,

I haven't used this lib on linux and also not all of its features, but I can confirm that it basically works with Qt 5.5.1 and 5.6.1 on Windows. From your log it seems that the app is crashing in the end, right? I had a similar issue in the past when setting global log level to TRACE. The reason seemed to be some trace messages that log4qt itself is plotting at shutdown, in combination with extensive use of static variables and the unclear order of static deinitialization. At some point some static log4qt object is destroyed, tries to plot trace messages and thus accesses other static lib parts that are already gone. This causes a mem access violation. As a workaround you can exclude log4qt from TRACE by putting something like "log4j.logger.Log4Qt=ERROR" into your config. If I ever have time again, I'll try to find those trace messages and remove them.

If this doesn't help or does not apply to your situation, I can only recommend to use a debugger to track it down.

Alex

JoeyJoeJoeJrShabadoo avatar Jul 25 '16 11:07 JoeyJoeJoeJrShabadoo

Thanks for the fast reply. Your fork of log4qt is the only one I've found compiling / running on Debian 8. All other projects requires Qt > 5.3 or the compilations fails. For more evaluation tests, I've changed the .pro files to get a shared libary. Doing this, I've made a second .pro for the tests to compile against this shared library. Using this test application, the result is the same (still 8 errors) but there is now segfault anymore. If you are insterested in the two .pro files, I can pass them to you.

By the way... how can I generate the documentation?

joede avatar Jul 25 '16 11:07 joede

Oops, my reply was a bit inadequate. I thought you we're creating your own test app, but just realized that there is one included in the sources. Unfortunately I never used it before and don't really know what it is doing. A quick compile revealed that I have 16 failed tests and also a crash at program exit. I'd not consider it relevant. Maybe the test app was not fully ported from the original log4qt. Maybe it pays to try creating your own test app.

Please note that this is not my project. I'm just using it and added a tiny bit regarding qint64 support. I can only say what I know from experience. Regarding documentation there is a Doxyfile included, so you should be able to use Doxygen to generate the docs. There's some more documentation on http://log4qt.sourceforge.net/html/index.html.

JoeyJoeJoeJrShabadoo avatar Jul 25 '16 12:07 JoeyJoeJoeJrShabadoo

I'm aware that your project here is a fork. Since all other forks doesn't work for me, this is my best choose. ;-) What are your experiences with the library (in general and on Windows)? Is it possible to log to the Windows "event log" ("event manager")?

I've tried the test app just to see the library working. I must be able to (optionally) log the serial communication of a small tool I've written (my first Qt app after years of using FLTK). This tool must run with Linux and Windows, so the logging must do too. I've compiled a library and the test app with MXE (MingW Cross Compiler with Qt 5.5.1) and there are failures too. Just to complete the issue, here is the output:

FAIL!  : Log4QtTest::RollingFileAppender() Compared values are not the same
   Actual   (mpLoggingEvents->list().count()): 8
   Expected (0)                              : 0
log4qttest.cpp(1853) : failure location
PASS   : Log4QtTest::cleanupTestCase()
Totals: 194 passed, 9 failed, 0 skipped, 0 blacklisted
********* Finished testing of Log4QtTest *********
pure virtual method called
terminate called without an active exception

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

joede avatar Jul 25 '16 12:07 joede

For my simple needs the lib does its job. I'm generally logging to a file. I don't think it supports the Windows event log out of the box. You would probably have to implement your own Appender class for that.

I'm compiling using Visual Studio 2010 natively on Windows, unfortunately I have no experience with MinGW. I'm using log4qt as static lib. I'm gonna attach a very simple app for testing. It loads a config file that defines a file appender and puts out a log message. SimpleLog4Qt.zip

JoeyJoeJoeJrShabadoo avatar Jul 25 '16 13:07 JoeyJoeJoeJrShabadoo

Thanks for the sample. May be you should add it to the project.

By the way... Do I need a explicit configuration file? Or is it possible to configure all the stuff inside the C++ code? I'm not shure how to locate the configuration file after an installation (using NSIS).

joede avatar Jul 26 '16 08:07 joede

I'm pretty sure that most things can be set directly using methods of the respective log4qt classes/objects, but I have never delved into that thoroughly. Instead you can use PropertyConfigurator::configure(const Log4Qt::Properties &). This version takes a Log4Qt::Properties object that is basically a string map where you can enter all things that are otherwise read from file, e.g.

Log4Qt::Properties tProps;
tProps.setProperty("log4j.appender.A1","org.apache.log4j.RollingFileAppender");
tProps.setProperty("log4j.appender.A1.file","TestApp.log");
...
Log4Qt::PropertyConfigurator::configure(tProps);

JoeyJoeJoeJrShabadoo avatar Jul 26 '16 09:07 JoeyJoeJoeJrShabadoo