到目前为止,我设法创建了一个Log4Qt配置文件并使用PropertyConfigurator加载它。一切似乎工作正常,我可以设置记录器,appenders,分配级别等 唯一不起作用的是为appender设置一个阈值。
这是我设置配置文件的方式:
void createNewLoggerConfigurationFile(QString fileName)
{
QSettings settings(fileName, QSettings::IniFormat);
settings.setValue("log4j.appender.A1", "org.apache.log4j.FileAppender");
settings.setValue("log4j.appender.A1.file", "C:/Users/Fujitsu/Desktop/LogOutput.txt");
settings.setValue("log4j.appender.A1.layout", "org.apache.log4j.TTCCLayout");
settings.setValue("log4j.appender.A1.layout.DateFormat", "ISO8601");
settings.setValue("log4j.appender.ADataManager", "org.apache.log4j.FileAppender");
settings.setValue("log4j.appender.ADataManager.file", "C:/Users/Fujitsu/Desktop/DataManagerLogOutput.txt");
settings.setValue("log4j.appender.ADataManager.layout", "org.apache.log4j.TTCCLayout");
settings.setValue("log4j.appender.ADataManager.layout.DateFormat", "ISO8601");
settings.setValue("log4j.appender.ADataManager.threshold", "DEBUG");
settings.setValue("log4j.rootLogger", "ALL, A1");
settings.setValue("log4j.logger.DataManager", "ALL, ADataManager");
}
生成的错误消息(来自Log4Qt,我猜)如下所示:
10 [] ERROR Log4Qt :: Factory - 无法转换为类'Log4Qt :: FileAppender'对象的属性'threshold'的'Level'类型(Log4Qt :: Factory :: CONFIGURATOR_UNKNOWN_TYPE_ERROR,29)
有什么想法吗?