Here you can find some simple notes on how to debug Qt / KDE applications. My focus is on OpenBSD as host system but everything here should work on GNU/Linux.
kDebug()
and friends have been deprecated in KDE Frameworks 5 so you have to
use the recommended logging functions qCDebug(category)
, qCInfo(category)
,
qCWarning(category)
qCCritical(category)
to create logs from Qt5/Qt6
applications. Since Qt 5.2 QLoggingCategory is available to configure the
category and allows us to control the output.
We can control it as follows and this is also the sequence as they are evaluated.
[QLibraryInfo::DataPath]/qtlogging.ini
QtProject/qtlogging.ini
setFilterRules()
QT_LOGGING_CONF
QT_LOGGING_RULES
In my default setup I disabled all debug logging in
~/.config/QtProject/qtlogging.ini
by a simple rule like this:
[Rules]
*.debug=false
and enable step by step by QT_LOGGING_RULES
what I want to see. For example,
debug KDE Frameworks export QT_LOGGING_RULES="kf.*.debug=true"
QT_FORCE_STDERR_LOGGING
is a other useful environment variable to help you to
debug from terminal. This ensure all your logs are going to stderr instead
syslog or journald. export QT_FORCE_STDERR_LOGGING=1
A common case is to see default debug messeages without a category like:
qDeug() << "Simple deug log message"
. This is possible due to the simple
logging rule QT_LOGGING_RULES="default.debug=true"
.
The pattern is always the same. Search for Q_DECLARE_LOGGING_CATEGORY
to
identify the log name and filter it with QT_LOGGING_RULES
Here you can find example: codesearch.debian.net - Q_DECLARE_LOGGING_CATEGORY
You can set the QT_LOGGING_DEBUG
environment variable to find out where your logging rules are loaded from.
For more informations checkout QLoggingCategory
docs.