#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; }
原文:http://blog.csdn.net/haifengzhilian/article/details/19824299