Giter Site home page Giter Site logo

meonmedical / log4qt Goto Github PK

View Code? Open in Web Editor NEW
554.0 47.0 228.0 1.12 MB

Log4Qt - Logging for the Qt cross-platform application framework

License: Apache License 2.0

QMake 1.51% C++ 93.13% C 0.21% CMake 3.62% QML 1.52%
qt-framework logging log4qt qt5 qmake logging-library cpp11 cpp cmake qbs

log4qt's People

Contributors

andibacher avatar bbilas avatar bf-bryants avatar chehrlic avatar debrouxl avatar filonenko-mikhail avatar johannanhofer avatar kmrashad avatar kuzzh avatar maleadt avatar murzz avatar nioncode avatar noksel avatar rangelreale avatar siyuhong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

log4qt's Issues

How to ensure log write to file on disk?

I use DailyFileAppender to write log, but when my program crashed or something broken, it can't see the latest log in file after restart program or reboot.(here is embedded Linux).

The WriteAppender use QTextStream::flush when immediateFlush is true, but it seems that it just only write it's internal buffer to filesystem.

Is there any something like QSaveFile which commit() save data to file? In fact, it call native sync method, which call fsync in linux.

Thanks in advance.

removeAppender must cause deadlock

void AppenderAttachable::removeAppender(const QString &name)
{
QWriteLocker locker(&mAppenderGuard); // it must be removed!
AppenderSharedPtr pAppender = appender(name);
if (pAppender)
removeAppender(pAppender);
}

Warnings when compiled for ARM

The following warnings are visible while compiling with android_armv7:
In file included from C:\Qt\5.6\android_armv7\include/QtCore/qhash.h:40:0,
from C:\Qt\5.6\android_armv7\include/QtCore/qshareddata.h:40,
from C:\Qt\5.6\android_armv7\include\QtCore/qsharedpointer.h:39,
from C:\Qt\5.6\android_armv7\include\QtCore/QSharedPointer:1,
from ......\Log4Qt\src\log4qt\log4qtsharedptr.h:4,
from ......\Log4Qt\src\log4qt\layout.h:29,
from ......\Log4Qt\src\log4qt\appender.h:28,
from ......\Log4Qt\src\log4qt\appenderskeleton.h:28,
from ......\Log4Qt\src\log4qt\appenderskeleton.cpp:25:
C:\Qt\5.6\android_armv7\include/QtCore/qlist.h: In instantiation of 'void QList::node_copy(QList::Node*, QList::Node*, QList::Node*) [with T = QVariant]':
C:\Qt\5.6\android_armv7\include/QtCore/qlist.h:805:58: required from 'QList::QList(const QList&) [with T = QVariant]'
......\Log4Qt\src\log4qt\helpers/logerror.h:498:12: required from here
C:\Qt\5.6\android_armv7\include/QtCore/qlist.h:465:17: warning: cast from 'QList::Node*' to 'QVariant*' increases required alignment of target type [-Wcast-align]
new (current) T(reinterpret_cast<T>(src));

Check the following thread for more info: https://groups.google.com/forum/#!topic/qt-project-list-development/CGZlE5o5Bic

I am using the following patch as a workaround (g++.pri):
win32 {
NORMAL_CXXFLAGS += -Wcast-align
}

Full build log:
build.txt

Regards,
ThE-MaRaC

release version log4qt Memory leak(OS:Windows)

The released project occupies more memory with the increase of logs,and not released.
The more debug or error log info taked ,the more memory will be occupied, but there is no phenomenon in the debug version.

Set %F %M %L in properties file, but it can't work in windows

I use Log4Qt-master code,and build in Qt 5.7.0.I set proterty through protpery file.I set " log4j.appender.daily.layout=org.apache.log4j.PatternLayout" and "log4j.appender.daily.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] [%F:%M:%L] %-5p [%c] - %m%n".But Output result is "[2018-11-14 12:20:08] [::-1] INFO [daily] - Test1",file name,method,line num are wrong.

%M%F%L in properties file work wrong

My env : log4qt-master, Qt 5.9.4, linux
My log4qt.properties:
logpath=./logs

log4j.reset=true
log4j.Debug=WARN
log4j.threshold=NULL
log4j.handleQtMessages=true
log4j.watchThisFile=false

log4j.rootLogger=ALL, daily

log4j.appender.daily=org.apache.log4j.DailyFileAppender
log4j.appender.daily.file=${logpath}/emb.log
log4j.appender.daily.appendFile=true
log4j.appender.daily.datePattern=_yyyy-MM-dd
log4j.appender.daily.keepDays=7
log4j.appender.daily.layout=org.apache.log4j.PatternLayout
log4j.appender.daily.layout.conversionPattern=%d{yyyy-MM-dd hh:mm:ss.zzz} [%p]<%c> (%t)%F:%L%n %M: %m%n

My output: emb_2017-08-05.log:
2017-08-05 17:32:03.050 [DEBUG] (0x000000001b798e90):0
: ModbusThread mbStart
2017-08-05 17:32:05.550 [DEBUG] (0x000000001b798e90):0
: showWorkFile

My app.pro has DEFINES += QT_MESSAGELOGCONTEXT
and log with qCDebug(embApp) << msg; or qDebug() << msg; in my source file.

How can i fix it?

Log4Qt-1.5.1\src\log4qt\ttcclayout.h:118, enum DateFormat has errors

Log4Qt-1.5.1\src\log4qt\ttcclayout.h:118, enum DateFormat has errors

The source code is written this:
enum DateFormat { /*! The none date format string is "NONE". */ NONE, /*! * The iso8601 date format string is "ISO8601". The date will be * formatted as yyyy-MM-dd hh:mm:ss.zzz. */ ISO8601, /*! * The absolute date format string is "ABSOLUTE". The date will be * formatted as HH:mm:ss.zzz. */ ABSOLUTE, /*! * The date date format string is "DATE". The date will be formatted * as MMM YYYY HH:mm:ss.zzz. */ DATE, /*! * The relative date format string is "RELATIVE". The date will be * formatted as milliseconds since start of the program. */ RELATIVE };
My programming environment is Windows, here the DateFormat enumeration values ABSOLUTE and RELATIVE will conflict with the Windows header files, for example
C: \ Program Files (x86) \ Windows Kits \ 10 \ Include \ 10.0.17763.0 \ um \ wingdi.h: 1903
/ * Coordinate Modes * /
#define ABSOLUTE 1
#define RELATIVE 2

I recommend changing the name of the DateFormat enum variable to something else.

log4qt/log4qtshared file not found

I had build and install log4qt as a shared library either in Ubuntu 18.04 and in IOs 10.14
in both enviroments I get successfull to link the dynamic library . The only one issue is that when I build my project I get an error 'log4qt/log4qtshared.h' in logerror.h file not found

why log4qt assert debug fail on windows?

i encountered the assert debug fail(heap allocate/free error) on windows platform when i link the static lib or dll, why this happens when i link the static lib?

compiling against Qt5.3 with msvc 19 error in v1.4.2

I'm trying to compile Log4Qt (v1.4.2 that you said is compatible down to Qt5.3) with msvc19 (2022) and for Qt5.3 but I will get a message regarding GCC?! below:
Log4Qt\src\log4qt\log4qt.h(484): fatal error C1189: #error: "Log4Qt requires at least gcc version 4.8 or higher for used c++11 features"
I don't get it what it have to do with GCC?

include in your project , The instructions seem incomplete

include in your project
Can also be used by adding the log4qt source directly to your Qt project file by adding the following line: include(/src/log4qt/log4qt.pri)
This doesn't seem to work, you still need to add build.pri and g++.pri,Is that right?

log4Qt cannot setEncoding

log4Qt version:1.5.0
writerappender.cpp

void WriterAppender::setEncoding(QTextCodec *encoding)
{
    QMutexLocker locker(&mObjectGuard);

    if (mEncoding == encoding)
        return;

    mEncoding = encoding;
    if (mWriter != nullptr)
    {
        if (mEncoding != nullptr)
            mWriter->setCodec(mEncoding);

        // Just annotate out this sentence
        mWriter->setCodec(QTextCodec::codecForLocale());
    }
}

dailyfileappender.cpp,need add #include <QStringBuilder>

dailyfileappender.cpp,need add #include < QStringBuilder >

QString DailyFileAppender::appendDateToFilename() const { QFileInfo fi(mOriginalFilename); return fi.absolutePath() % QStringLiteral("/") % fi.baseName() % mLastDate.toString(mDatePattern) % QStringLiteral(".") % fi.completeSuffix(); }

Because "%" is an overloaded operator, if the source file does not include this header file #include < QStringBuilder >, it will conflict with "%" overloaded operators of other third-party libraries.

Once a AppenderSkeleton called close(),it can't be opened any more.

In AppenderSkeleton::closeInternal(), set mIsClosed to true, and set mIsActive to false.
But in AppenderSkeleton::activateOptions(), it only set mIsActive to true.
Is there have some special reason?
I want to close a FileAppender, at sometime reactivate it, the mIsClosed block my way.

How do you handle Obsolete Qt Calls

For example, in file systemlogappender.cpp line 163, you have for (const auto &line : message.split('\n', QString::SkipEmptyParts)), QString::SkipEmptyParts is Obsoleted as of 5.15 at least, and replaced with Qt::SkipEmptyParts, normally I would handle it like:

#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) // Set to lowest version required
    for (const auto &line : message.split('\n', Qt::SkipEmptyParts))
#else
    for (const auto &line : message.split('\n', QString::SkipEmptyParts))
#endif

Thanks, Flesh

log missing

OS: win10
qt 5.10.0
c++11
Using logDailyFile ,during a long run, the log suddenly stops recording, but the software runs normally ,error judgments were seen in the code and no error records were found in the log .
must multithreading use mainThreadappender ?mainThreadappender whether scrolling by log can be set ?

Failed build with MXE cross compiler (Mingw)

I've tried to build the library and the examples with the MXE cross compiler on Debian 8. While the library is build without problems, the examples and the test application can't be built. The linking process aborts with unresolved externals. I've put the (stripped down) output of the build into a gist.

https://gist.github.com/joede/279e36de061c422b5dcf097e307d2581

There is a bug in log4qt.pro. The inclusion of g++.pri uses the wrong path. It should be ../../g++.pri. Fixing the path leads to the same linking errors.

MXE uses g++ 4.9.3 and Qt 5.5.1!

Building log4qt on Debian 8 itself works very well and the test application finish without any failures. Debian 8 comes with g++ 4.9.2 and Qt 5.3!

memory leak in windows? The more debug log info taked ,the more memory will be occupied

i have a problem when using log4qt in windows,
The more debug or error log info taked ,the more memory will be occupied.
is there any memory leak in windows? i just did a simple test by qtcreator project,using log4qt version 1.5.0

let me show the picture when running the test for one hour, the memory occupied from 6M to 456M
image
image

my log config is:
log4j.rootLogger=DEBUG,daily,console

log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%-d [%t] %-5p: %m%n
log4j.appender.logfile.File=./log/uiTest.log
log4j.appender.logfile.ImmediateFlush=FALSE
log4j.appender.logfile.Threshold=DEBUG
log4j.appender.logfile.AppendFile=TRUE

log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-d [%t] %-5p: %m%n

log4j.appender.daily=org.apache.log4j.DailyFileAppender
log4j.appender.daily.file=./log/uiTest.log
log4j.appender.daily.appendFile=true
log4j.appender.daily.datePattern=_yyyy_MM_dd
#log4j.appender.daily.keepDays=90
log4j.appender.daily.layout=${log4j.appender.console.layout}
#log4j.appender.daily.layout.dateFormat=${log4j.appender.console.layout.dateFormat}

log4j.appender.daily.layout.ConversionPattern=%-d [%t] %-5p: %m%n
#log4j.appender.daily.layout.contextPrinting=${log4j.appender.console.layout.contextPrinting}

my test example is like this:

`void MainWindow::on_pushButton_clicked()
{
ui->pushButton->setEnabled(false);
QFuture future = QtConcurrent::run(&
{
int count = 0;
while(1)
{
QMutex mutex;
QMutexLocker locker(&mutex);
logger->info("&&&&&on_pushButton_clicked&&&&&&&",FILE,FUNCTION,QString::number(LINE));
QThread::msleep(5);
count++;
}
});
}

void MainWindow::on_pushButton_2_clicked()
{
ui->pushButton_2->setEnabled(false);
QFuture future = QtConcurrent::run(&
{
int count = 0;
while(1)
{
QMutex mutex;
QMutexLocker locker(&mutex);
logger->info("&&&&&on_pushButton_2_clicked&&&&&&&",FILE,FUNCTION,QString::number(LINE));
QThread::msleep(5);
count++;
}
});
}`

Wrong installation directories

I use /usr/bin/qmake from Linux Mint distribution.
Commands qmake; make; make install do install to catalogs /lib and /include.
It should be installed to /usr/lib and /usr/include.

Log from installation:

jacek@kaczorek:~/Projekty/Qt/Log4Qt$ sudo make install cd src/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/jacek/Projekty/Qt/Log4Qt/src/src.pro ) && make -f Makefile install make[1]: Entering directory '/home/jacek/Projekty/Qt/Log4Qt/src' cd log4qt/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/log4qt.pro ) && make -f Makefile install make[2]: Entering directory '/home/jacek/Projekty/Qt/Log4Qt/src/log4qt' /usr/lib/qt5/bin/qmake -install qinstall -exe ../../bin/liblog4qt.so.1.0.0 /lib/liblog4qt.so.1.0.0 strip --strip-unneeded /lib/liblog4qt.so.1.0.0 ln -f -s liblog4qt.so.1.0.0 /lib/liblog4qt.so ln -f -s liblog4qt.so.1.0.0 /lib/liblog4qt.so.1 ln -f -s liblog4qt.so.1.0.0 /lib/liblog4qt.so.1.0 /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/appender.h /include/log4qt/appender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/appenderskeleton.h /include/log4qt/appenderskeleton.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/asyncappender.h /include/log4qt/asyncappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/basicconfigurator.h /include/log4qt/basicconfigurator.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/binaryfileappender.h /include/log4qt/binaryfileappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/binarylayout.h /include/log4qt/binarylayout.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/binarylogger.h /include/log4qt/binarylogger.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/binaryloggingevent.h /include/log4qt/binaryloggingevent.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/binarylogstream.h /include/log4qt/binarylogstream.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/binarytotextlayout.h /include/log4qt/binarytotextlayout.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/binarywriterappender.h /include/log4qt/binarywriterappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/consoleappender.h /include/log4qt/consoleappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/dailyfileappender.h /include/log4qt/dailyfileappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/dailyrollingfileappender.h /include/log4qt/dailyrollingfileappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/fileappender.h /include/log4qt/fileappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/hierarchy.h /include/log4qt/hierarchy.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/layout.h /include/log4qt/layout.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/level.h /include/log4qt/level.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/log4qt.h /include/log4qt/log4qt.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/log4qtshared.h /include/log4qt/log4qtshared.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/log4qtsharedptr.h /include/log4qt/log4qtsharedptr.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/logger.h /include/log4qt/logger.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/loggerrepository.h /include/log4qt/loggerrepository.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/loggingevent.h /include/log4qt/loggingevent.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/logmanager.h /include/log4qt/logmanager.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/logstream.h /include/log4qt/logstream.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/mainthreadappender.h /include/log4qt/mainthreadappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/mdc.h /include/log4qt/mdc.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/ndc.h /include/log4qt/ndc.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/patternlayout.h /include/log4qt/patternlayout.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/propertyconfigurator.h /include/log4qt/propertyconfigurator.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/qmllogger.h /include/log4qt/qmllogger.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/rollingbinaryfileappender.h /include/log4qt/rollingbinaryfileappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/rollingfileappender.h /include/log4qt/rollingfileappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/signalappender.h /include/log4qt/signalappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/simplelayout.h /include/log4qt/simplelayout.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/simpletimelayout.h /include/log4qt/simpletimelayout.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/systemlogappender.h /include/log4qt/systemlogappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/ttcclayout.h /include/log4qt/ttcclayout.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/writerappender.h /include/log4qt/writerappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/xmllayout.h /include/log4qt/xmllayout.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/telnetappender.h /include/log4qt/telnetappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/helpers/appenderattachable.h /include/log4qt/helpers/appenderattachable.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/helpers/binaryclasslogger.h /include/log4qt/helpers/binaryclasslogger.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/helpers/classlogger.h /include/log4qt/helpers/classlogger.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/helpers/configuratorhelper.h /include/log4qt/helpers/configuratorhelper.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/helpers/datetime.h /include/log4qt/helpers/datetime.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/helpers/dispatcher.h /include/log4qt/helpers/dispatcher.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/helpers/factory.h /include/log4qt/helpers/factory.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/helpers/initialisationhelper.h /include/log4qt/helpers/initialisationhelper.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/helpers/logerror.h /include/log4qt/helpers/logerror.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/helpers/optionconverter.h /include/log4qt/helpers/optionconverter.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/helpers/patternformatter.h /include/log4qt/helpers/patternformatter.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/helpers/properties.h /include/log4qt/helpers/properties.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/spi/filter.h /include/log4qt/spi/filter.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/varia/binaryeventfilter.h /include/log4qt/varia/binaryeventfilter.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/varia/debugappender.h /include/log4qt/varia/debugappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/varia/denyallfilter.h /include/log4qt/varia/denyallfilter.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/varia/levelmatchfilter.h /include/log4qt/varia/levelmatchfilter.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/varia/levelrangefilter.h /include/log4qt/varia/levelrangefilter.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/varia/listappender.h /include/log4qt/varia/listappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/varia/nullappender.h /include/log4qt/varia/nullappender.h /usr/lib/qt5/bin/qmake -install qinstall /home/jacek/Projekty/Qt/Log4Qt/src/log4qt/varia/stringmatchfilter.h /include/log4qt/varia/stringmatchfilter.h make[2]: Leaving directory '/home/jacek/Projekty/Qt/Log4Qt/src/log4qt' make[1]: Leaving directory '/home/jacek/Projekty/Qt/Log4Qt/src' cd tests/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/jacek/Projekty/Qt/Log4Qt/tests/tests.pro ) && make -f Makefile install make[1]: Entering directory '/home/jacek/Projekty/Qt/Log4Qt/tests' cd log4qttest/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/jacek/Projekty/Qt/Log4Qt/tests/log4qttest/log4qttest.pro ) && make -f Makefile install make[2]: Entering directory '/home/jacek/Projekty/Qt/Log4Qt/tests/log4qttest' make[2]: Nothing to be done for 'install'. make[2]: Leaving directory '/home/jacek/Projekty/Qt/Log4Qt/tests/log4qttest' cd binaryloggertest/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/jacek/Projekty/Qt/Log4Qt/tests/binaryloggertest/binaryloggertest.pro ) && make -f Makefile install make[2]: Entering directory '/home/jacek/Projekty/Qt/Log4Qt/tests/binaryloggertest' make[2]: Nothing to be done for 'install'. make[2]: Leaving directory '/home/jacek/Projekty/Qt/Log4Qt/tests/binaryloggertest' cd dailyfileappendertest/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/jacek/Projekty/Qt/Log4Qt/tests/dailyfileappendertest/dailyfileappendertest.pro ) && make -f Makefile install make[2]: Entering directory '/home/jacek/Projekty/Qt/Log4Qt/tests/dailyfileappendertest' make[2]: Nothing to be done for 'install'. make[2]: Leaving directory '/home/jacek/Projekty/Qt/Log4Qt/tests/dailyfileappendertest' cd filewatcher/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/jacek/Projekty/Qt/Log4Qt/tests/filewatcher/filewatcher.pro ) && make -f Makefile install make[2]: Entering directory '/home/jacek/Projekty/Qt/Log4Qt/tests/filewatcher' make[2]: Nothing to be done for 'install'. make[2]: Leaving directory '/home/jacek/Projekty/Qt/Log4Qt/tests/filewatcher' make[1]: Leaving directory '/home/jacek/Projekty/Qt/Log4Qt/tests' cd examples/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/jacek/Projekty/Qt/Log4Qt/examples/examples.pro ) && make -f Makefile install make[1]: Entering directory '/home/jacek/Projekty/Qt/Log4Qt/examples' cd basic/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/jacek/Projekty/Qt/Log4Qt/examples/basic/basic.pro ) && make -f Makefile install make[2]: Entering directory '/home/jacek/Projekty/Qt/Log4Qt/examples/basic' make[2]: Nothing to be done for 'install'. make[2]: Leaving directory '/home/jacek/Projekty/Qt/Log4Qt/examples/basic' cd propertyconfigurator/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/jacek/Projekty/Qt/Log4Qt/examples/propertyconfigurator/propertyconfigurator.pro ) && make -f Makefile install make[2]: Entering directory '/home/jacek/Projekty/Qt/Log4Qt/examples/propertyconfigurator' make[2]: Nothing to be done for 'install'. make[2]: Leaving directory '/home/jacek/Projekty/Qt/Log4Qt/examples/propertyconfigurator' make[1]: Leaving directory '/home/jacek/Projekty/Qt/Log4Qt/examples'

when log4qtd is lanuched in debug mode,exception will occurred

qt 5.12.6

demo url: https://github.com/jk553633/Log4qtDemo

1 QVariant::QVariant Qt5Cored 0x7ffd6026b95d
2 QVariant::QVariant Qt5Cored 0x7ffd60455d11
3 Log4Qt::operator<< logerror.cpp 166 0x7ffdae19bdbc
4 QtMetaTypePrivate::QMetaTypeFunctionHelperLog4Qt::LogError,1::Save qmetatype.h 811 0x7ffdae19ab6d
5 QVariant::QVariant Qt5Cored 0x7ffd606cd30a
6 qt_plugin_instance qmldbg_debuggerd 0x7ffdacc9b493
7 qt_plugin_instance qmldbg_debuggerd 0x7ffdacc99997
8 qt_plugin_instance qmldbg_debuggerd 0x7ffdacc98149
9 qt_plugin_instance qmldbg_debuggerd 0x7ffdacca11e9
10 qt_plugin_instance qmldbg_debuggerd 0x7ffdacc9cda7
11 qt_plugin_instance qmldbg_debuggerd 0x7ffdacca33ce
12 QVariant::QVariant Qt5Cored 0x7ffd606ca968
13 QVariant::QVariant Qt5Cored 0x7ffd607089de
14 QVariant::QVariant Qt5Cored 0x7ffd60708288
15 qt_plugin_instance qmldbg_debuggerd 0x7ffdacca6de4
16 qt_plugin_instance qmldbg_debuggerd 0x7ffdacca739a
17 qt_plugin_instance qmldbg_debuggerd 0x7ffdacca6ec3
18 qt_plugin_instance qmldbg_debuggerd 0x7ffdacca6a6c
19 qt_plugin_instance qmldbg_debuggerd 0x7ffdacc976d7
20 qt_plugin_instance qmldbg_debuggerd 0x7ffdacca125e
... <更多>

logerror.h line 158
#ifndef QT_NO_DATASTREAM
QDataStream &operator<<(QDataStream &out,
const LogError &logError)
{
// version
quint16 version = 0;
out << version;
// version 0 data
out << logError.mCode
<< logError.mContext
<< logError.mMessage
<< logError.mSymbol
<< logError.mArgs
<< logError.mCausingErrors;

return out;

}


Exception Triggered

The inferior stopped because it triggered an exception.

Stopped in thread 0 by: Exception at 0x7ffd4c9ab95d, code: 0xc0000005: read access violation at: 0x4, flags=0x0 (first chance). --------------------------- OK ---------------------------

when log4qtd is lanuched in debug mode,exception will occurred at logerror.h line 166(out << logError.mCode).

log4Qt cannot output source file names, line numbers, function names, etc.

log4Qt cannot output source file names, line numbers, function names, etc.

log4Qt version:1.5.1
My program:main.cpp

#include
#include
#include

#include <log4qt/consoleappender.h>
#include <log4qt/logger.h>
#include <log4qt/loggerrepository.h>
#include <log4qt/patternlayout.h>

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

Log4Qt::Logger *logger = Log4Qt::Logger::rootLogger();
Log4Qt::PatternLayout *layout = new Log4Qt::PatternLayout();
layout->setHeader("----- start -----");
layout->setFooter("----- end -----");
layout->setConversionPattern("%d{yyyy-MM-dd hh:mm:ss} [%p] %c{2} %M.%L %x - %m%n");
layout->activateOptions();

// ConsoleAppender
Log4Qt::ConsoleAppender *appender = new Log4Qt::ConsoleAppender(layout, 
Log4Qt::ConsoleAppender::STDOUT_TARGET);
appender->activateOptions();
logger->addAppender(appender);

logger->setLevel(Log4Qt::Level::DEBUG_INT);
logger->debug("Debug, Log4Qt!");
logger->info("Info, Log4Qt!");

//shutdown
logger->removeAllAppenders();
logger->loggerRepository()->shutdown();

return a.exec();

}

The results are as follows:
----- start -----
2020-03-24 21:08:14 [DEBUG] root .-1 - Debug, Log4Qt!
2020-03-24 21:08:14 [INFO] root .-1 - Info, Log4Qt!
----- end -----

I used "%M.%L", but log4Qt cannot output source file names, line numbers, function names, etc.
why?

Unable to write file

os: win10
qt:5.10.0
std:c++11
compiler:vs2015

Encapsulated as a singleton mode, in a multi-threaded environment, the use of DailyFileAppender mode, sometimes cannot write to the file and no error msg.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.