一.为啥使用log4Qt?
1.与log4cpp的用法相似,支持配置文件。
2.可以输出qDebug(),qInfo()等等Qt自带的打印信息。
二.工程地址
MEONMedical/Log4Qt: Log4Qt - Logging for the Qt cross-platform application framework (github.com)
编译按照上面的步骤编译即可。
三.log4cpp使用
1.将log4cpp封装成新类,支持qml和cpp两用。
log.h
#ifndef LOG_H
#define LOG_H
#include <QObject>
#include <QQmlEngine>
#include <QMutex>
class Log : public QObject
{
Q_OBJECT
public:
enum LogLevel{
ACTIVE = 0,
INFO,
DEBUG,
FATAL,
CLOSE
};
Q_ENUM(LogLevel)
explicit Log(QObject *parent = nullptr) {};
~Log() {};
Log(const Log&) = delete;
Log& operator=(const Log&) = delete;
标签:Log4Qt,Qt,QObject,日志,include,log4cpp,Log
From: https://blog.csdn.net/cs821984831/article/details/140790036