Qt HTTP Server Registro
El servidor Qt HTTP Server utiliza la clase QLoggingCategory para el registro. Las categorías de registro que comienzan por "qt.httpserver" son utilizadas por las diferentes partes del Qt HTTP Server. Estas pueden activarse y desactivarse tal y como se describe en QLoggingCategory.
Para activar o desactivar dinámicamente lo que se registra, llama a QLoggingCategory::setFilterRules(). Un servidor puede añadir una URL para cambiar las reglas de filtrado, utilizando la función QHttpServer::route() tal y como se muestra a continuación.
#include <QCoreApplication>
#include <QHttpServer>
#include <QLoggingCategory>
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
QHttpServer server;
auto tcpserver = std::make_unique<QTcpServer>();
if (!tcpserver->listen(QHostAddress::LocalHost, 8000) || !server.bind(tcpserver.get()))
return -1;
tcpserver.release();
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;
}
QLoggingCategory::setFilterRules(filter);
return filter;
});
return app.exec();
}Ahora las reglas de filtrado se pueden configurar utilizando: "http://127.0.0.1:8000/loggingFilter?qt.httpserver=true&appname.access=true". En este caso, se habilitará todo el registro de Qt HTTP Server y, además, se habilitará la categoría de registro hipotética appname.access.
Véase también QLoggingCategory y QHttpServer.
© 2026 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.