对整个项目使用Poco::Logger
Using Poco::Logger for entire project
AutoPtr<SplitterChannel> splitterChannel(new SplitterChannel());
AutoPtr<Channel> consoleChannel(new ConsoleChannel());
AutoPtr<Channel> fileChannel(new FileChannel("Arcanite.log"));
AutoPtr<FileChannel> rotatedFileChannel(new FileChannel("Arcanite_R.log"));
rotatedFileChannel->setProperty("rotation", "100");
rotatedFileChannel->setProperty("archive", "timestamp");
splitterChannel->addChannel(consoleChannel);
splitterChannel->addChannel(fileChannel);
splitterChannel->addChannel(rotatedFileChannel);
//"%d-%m-%Y %H:%M:%S: %t"
AutoPtr<Formatter> formatter(new PatternFormatter("%d-%m-%Y %H:%M:%S %s: %t"));
AutoPtr<Channel> formattingChannel(new FormattingChannel(formatter, splitterChannel));
Logger& sLog = Logger::create("LogChan", formattingChannel, Message::PRIO_TRACE);
我写了我的记录器,我想使用我的服务器,在多个类。我该如何调整这个来做这个?这可能是基本的c++,但我似乎错过了一些教训:P
类Poco::Logger作为日志框架工作。
当您使用固定的名称(在您的示例中为"LogChan")定义记录器实例时,可以从所有类访问它。所以你应该写一个
Logger& logger = Logger::get("logChan");
从其他类中获取记录器引用。
我猜下面它使用单例模式来生成记录器池
相关文章:
- POCO::PostgreSQL:如何将std::vector支持添加到`Binder::bind`
- Poco FindMySql.cmake 无法找到 MySQL 源代码
- 像 POCO 这样的C++图书馆如何访问网络?
- Poco::Net::FTPClientSession 在 open() 方法上挂起 129 秒,如果 ftp 主机不存
- 使用 Poco::Zip 将文件附加到现有 zip 文件
- 无法使用 Poco 库正确克隆 JSON 数组C++
- Poco 库 PUT 方法未按预期工作,尽管主机、方法、内容类型设置正确
- POCO C++对象到 JSON 字符串序列化
- 错误:字段'dateOfBirth'的类型不完整'Poco::Data::Date'
- POCO C++加密/解密
- C++ POCO - 如何在不使用 run() 方法的情况下启动线程池上的线程?
- 使用 Poco::zip 添加新目录始终给出异常
- C++ Poco - 如何创建通知队列的向量?
- 如何使用 Poco::ZIP 压缩/解压缩 zip 文件
- 如何使用poco :: logger记录Unicode字符串
- Poco::Logger 不记录跟踪或调试级别日志,只记录信息级别及以上
- Poco Logger更改消息参数
- Linux上Poco::Logger的编译器错误-函数声明被视为宏
- Poco::Logger线程安全吗?
- 对整个项目使用Poco::Logger