#include "Poco/Logger.h"
#include "Poco/FormattingChannel.h"
#include "Poco/PatternFormatter.h"
#include "Poco/FileChannel.h"
#include "Poco/Message.h"
using Poco::Logger;
using Poco::PatternFormatter;
using Poco::FormattingChannel;
using Poco::FileChannel;
using Poco::Message;
#pragma comment(lib,"PocoFoundationd.lib")
int main()
{
FormattingChannel *pFCFile = NULL;
pFCFile = new FormattingChannel(new PatternFormatter("%Y-%m-%d %H:%M:%S.%c %U %u %N[%P]:%s:%q:%t"));
pFCFile->setChannel(new FileChannel("./sample.log"));
pFCFile->open();
Logger &fileLogger = Logger::create("FileLogger", pFCFile, Message::PRIO_DEBUG);
fileLogger.debug("an debug msg!", "main.cpp", 24);//24表示行号
fileLogger.information("an info msg!");
fileLogger.error("an error msg!");
fileLogger.fatal("an fatal msg!");
pFCFile->close();
return 0;
}
POCO开源库的日志使用示例
最新推荐文章于 2024-09-13 16:00:33 发布