Apache Log4cxx Version 1.0.0
Loading...
Searching...
No Matches
Qt Support

When using Qt, messages from the Qt framework itself or other libraries may use the QDebug classes. By default, this will print to stderr, thus bypassing the logger entirely. In order to have these messages routed to Log4cxx, a message handler for Qt must be installed.

Log4cxx provides a separate library, log4cxx-qt, which contains useful utilities for working with Qt.

To install a message handler that will route the Qt logging messages through Log4cxx, include the messagehandler.h and call qInstallMessageHandler as follows:

...
qInstallMessageHandler( log4cxx::qt::messageHandler );
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message)
The messageHandler function is a log4cxx replacement of the standard Qt message handler.

Note that by default, this message handler also calls abort upon a fatal message.