首页 > 其他 > 详细

PoCo 日志加时间戳

时间:2014-02-25 12:41:57      阅读:481      评论:0      收藏:0      [点我收藏+]
#include "Poco/ConsoleChannel.h"
#include "Poco/FormattingChannel.h"
#include "Poco/PatternFormatter.h"
#include "Poco/Logger.h"
#include "Poco/AutoPtr.h"
#include "Poco/FileChannel.h"

#include "Poco/Thread.h"
#include "Poco/Runnable.h"

using Poco::ConsoleChannel;
using Poco::FormattingChannel;
using Poco::PatternFormatter;
using Poco::Logger;
using Poco::AutoPtr;
using Poco::FileChannel;
using Poco::Thread;

int main(int argc, char** argv)
{
	//AutoPtr<ConsoleChannel> pCons(new ConsoleChannel);

	AutoPtr<FileChannel> pChannel(new FileChannel);
	pChannel->setProperty("path", "Iris.log");
	pChannel->setProperty("rotation", "never");
	pChannel->setProperty("archive", "timestamp");
	//Logger::root().setChannel(pChannel);

	AutoPtr<PatternFormatter> pPF(new PatternFormatter);
	pPF->setProperty("pattern", "%Y-%m-%d %H:%M:%S %s: %t");
	AutoPtr<FormattingChannel> pFC(new FormattingChannel(pPF, pChannel));
	Logger::root().setChannel(pFC);
	Logger::get("TestChannel").information("This is a test");
	return 0;
}

PoCo 日志加时间戳

原文:http://blog.csdn.net/haifengzhilian/article/details/19824299

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!