Poco记录器在进程重新启动时不会将日志附加到现有日志文件中
Poco logger does not append logs to existing log file on process restart
我正在为我的项目使用poco记录器。我想有一个行为,如果进程重启,poco不创建一个新的日志文件。下面是我的配置:我做错了什么?我发现每次重新启动时,poco都会覆盖日志,而不是附加到之前的日志中。
AutoPtr<FileChannel> pFile(new FileChannel(logfile));
pFile->setProperty("rotateOnOpen","true");
pFile->setProperty("rotation","1 M");
pFile->setProperty("archive", "timestamp");
pFile->setProperty("compress", "true");
pFile->setProperty("purgeAge", "1 months");
AutoPtr<Formatter> pformatter(new PatternFormatter("%d-%m-%Y %H:%M:%S %s: %t"));
pformatter->setProperty("times","local");
AutoPtr<Channel> pformattingchannel(new FormattingChannel(pformatter,pFile));
Logger::root().setChannel(pformattingchannel);
Logger::root().setLevel(Poco::Message::PRIO_INFORMATION);
您特别要求在打开时旋转日志文件:
pFile->setProperty("rotateOnOpen","true");
文档:
rotateOnOpen属性指定在打开通道时是否应该旋转(并存档)现有的日志文件。有效值为:
- true:打开通道时,日志文件被旋转(并存档)。
- false:日志消息将被附加到现有的日志文件,如果它存在(除非满足其他条件的旋转)。
相关文章:
- 加快在C++中读取/处理日志文件的速度
- 如何将消息时间戳写入日志文件?
- 分析包含 NMEA 句子的日志文件C++
- 如何从日志文件中抓取状态代码?(在 C++ 中)
- 未创建日志文件
- 尝试使用 EvtSetChannelConfigProperty() 函数更新最大事件日志文件大小时插入的错误值
- 提升日志:文件轮换
- POSIX C/C++日志文件(VEX V5 Brain)
- boost日志文件无法创建sample.log文件
- 哪个更适合从C++写入敏感的日志文件,在文件描述符上写()或文件上的fprintf()?
- 如何编写日志文件,以便可以使用记事本实时读取它以进行C++
- 如何在QT中使用DEBUG对齐日志文件中的数据?
- Qt - 如何在 30 天后删除日志文件,文件名不固定
- Mac OS X:应用程序可以创建日志文件
- 将断言消息写入日志文件
- 检查日志文件以找出 vcredist.exe 安装失败的原因
- C++同时记录到控制台和日志文件
- 无法创建将包含日志文件的文件夹
- (罗)如何使用相对路径保存日志文件
- boost::log关闭日志文件并打开一个新文件