Qt HTTP Server Logging

The Qt HTTP Server logs using the QLoggingCategory class. The logging categories starting with "qt.httpserver" are used by the different parts of the Qt Http Server. These can be enabled and disabled as described in QLoggingCategory.

To dynamically enable or disable what is being logged call QLoggingCategory::setFilterRules(). A server can add a URL to change the filter rules, by using the QHttpServer::route() function as shown below.

#include <QCoreApplication>
#include <QHttpServer>
#include <QLoggingCategory>

int main(int argc, char** argv)
    QCoreApplication app(argc, argv);
    QHttpServer server;
    server.listen(QHostAddress::LocalHost, 8000);

    server.route("/loggingFilter", [] (const QHttpServerRequest &request) {
        QString filter;
        QTextStream result(&filter);
        for (auto pair : request.query().queryItems()) {
            if (!filter.isEmpty())
                result << "\n";
            result << pair.first << "=" << pair.second;
        return filter;

    return app.exec();

The filter rules can now be set using: "". In this case all Qt HTTP Server logging will be enabled, and in addition the hypothetical logging category "appname.access" is enabled.

See also QLoggingCategory and QHttpServer.

© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.