log4Qt cannot output source file names, line numbers, function names, etc.
libaineu2004 opened this issue · 2 comments
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?
Look at #37 I think there is described why it does not work.
Look at #37 I think there is described why it does not work.
ok