I've setup a simple example using Poco::FileChannel, on which I call setProperty("rotation", "daily"). To test the rotation, I'm testing a scenario where the log file doesn't exist.
However, the hour on the rotation tag is incorrect (the hour on the log entry is correct):
# Log file created/rotated Wednesday, 27 Jun 12 18:12:03 GMT
2012-06-27 19:12:03.287 [Information] [test_logger][../Tests/main_logger_basic.cpp:27] Just getting started
From what I could gather, the problem (assuming I'm not doing anything wrong) seems to be here (file RotateStrategy.cpp):
- Code: Select all
bool RotateByIntervalStrategy::mustRotate(LogFile* pFile)
(...)
else
{
_lastRotate.update();
std::string tag(ROTATE_TEXT);
DateTimeFormatter::append(tag, _lastRotate, DateTimeFormat::RFC1036_FORMAT);
pFile->write(tag);
}
(...)
I see nothing here that checks/uses local time. Is this by design? An oversight? Or am I doing anything wrong?
My test code follows:
- Code: Select all
#include "Poco/Logger.h"
#include "Poco/FileChannel.h"
#include "Poco/FormattingChannel.h"
#include "Poco/PatternFormatter.h"
#include "Poco/AutoPtr.h"
int main(int argc, char *argv[])
{
Poco::Logger& l = Poco::Logger::get("test_logger");
Poco::AutoPtr <Poco::FormattingChannel> f(new Poco::FormattingChannel(new
Poco::PatternFormatter("%Y-%m-%d %H:%M:%S.%i [%p] [%s][%U:%u] %t")));
f->getFormatter()->setProperty("times", "local");
Poco::AutoPtr<Poco::FileChannel> fc(new Poco::FileChannel());
fc->setProperty("path", "teste.log");
fc->setProperty("times", "local");
fc->setProperty("rotation", "daily");
fc->setProperty("archive", "timestamp");
fc->setProperty("compress", "true");
fc->setProperty("purgeAge", "3 days");
l.setLevel(Poco::Message::PRIO_INFORMATION);
f->setChannel(fc);
l.setChannel(f);
poco_information(l, "Just getting started");
}
TIA
Paulo Caetano





