Qt HTTP Server Registro de eventos
O Qt HTTP Server registra em log usando a classe QLoggingCategory. As categorias de registro em log que começam com "qt.httpserver" são utilizadas pelas diferentes partes do Qt HTTP Server. Elas podem ser ativadas e desativadas conforme descrito em QLoggingCategory.
Para ativar ou desativar dinamicamente o que está sendo registrado, chame QLoggingCategory::setFilterRules(). Um servidor pode adicionar uma URL para alterar as regras de filtragem, utilizando a função QHttpServer::route() conforme mostrado abaixo.
#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();
}As regras de filtragem agora podem ser definidas usando: ` "http://127.0.0.1:8000/loggingFilter?qt.httpserver=true&appname.access=true"`. Nesse caso, todo o registro de ` Qt HTTP Server ` será ativado e, além disso, a categoria hipotética de registro ` appname.access ` será ativada.
Veja também QLoggingCategory e 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.