无法将splitterChannel与高级xml配置一起使用
Unable to use splitterChannel with advanced xml configuration with poco
我想使用poco和它的配置文件配置一个高级记录器。我创建了这样一个config.xml文件:
<?xml version="1.0" ?>
<Application>
<logging>
<channels>
<c1>
<class>ColorConsoleChannel</class>
<formatter>
<class>PatternFormatter</class>
<pattern>%Y-%m-%d %H:%M:%S : %s : [%p] : %t</pattern>
</formatter>
<traceColor>lightBlue</traceColor>
<debugColor>blue</debugColor>
<informationColor>green</informationColor>
<noticeColor>green</noticeColor>
<warningColor>yellow</warningColor>
<errorColor>red</errorColor>
<criticalColor>lightMagenta</criticalColor>
<fatalColor>lightMagenta</fatalColor>
</c1>
<c2>
<class>FileChannel</class>
<path>logs/traceApplication.log</path>
<rotation>1 M</rotation>
<archive>number</archive>
<purgeCount>5</purgeCount>
<formatter>
<class>PatternFormatter</class>
<pattern>%Y-%m-%d %H:%M:%S : %T : [%p] : %t</pattern>
</formatter>
</c2>
</channels>
<loggers>
<consoleLogger>
<channel>c1</channel>
<level>information</level>
</consoleLogger>
<traceFileLogger>
<channel>c2</channel>
<level>trace</level>
</traceFileLogger>
</loggers>
<channels>
<cSplitter>
<class>SplitterChannel</class>
<channels>consoleLogger,traceFileLogger,mainFileLogger</channels>
</cSplitter>
</channels>
<loggers>
<root>
<channel>cSplitter</channel>
<level>trace</level>
</root>
</loggers>
</logging>
</Application>
我使用Poco::Util::ServerApplication类,并在初始化方法中放入:
void CBS2AudioVideo::initialize(Poco::Util::Application& self)
{
loadConfiguration("config.xml");
Poco::Util::ServerApplication::initialize(self);
}
在添加splitterChannel之前,我的日志工作得很好,但是有了它,它就不再工作了。
我得到了错误信息:
未找到:日志通道:consoleLogger
我的目标是只有一个根记录器,当我使用它时,它以信息级别登录到控制台,并以跟踪级别登录到文件。
当我在channels. csplitter .channels中设置通道时,它可以工作,但所有通道都被记录到相同的级别。如果我使用日志配置幻灯片(http://pocoproject.org/slides/185-LoggingConfiguration.pdf),它们在logging.channels.splitter.channels属性区域中使用记录器而不是通道。所以我认为这是可能的。更多的Logger类也从Channel继承。
有人已经做过这样的工作或者有这样的想法吗?
我终于找到解决办法了。如果有人感兴趣,我把它贴在这里。
这个文件运行良好。
<?xml version="1.0" ?>
<Application>
<logging>
<channels>
<cScreen>
<class>ColorConsoleChannel</class>
<formatter>
<class>PatternFormatter</class>
<pattern>%H:%M:%S : %T : [%p] : %t</pattern>
</formatter>
<traceColor>lightBlue</traceColor>
<debugColor>blue</debugColor>
<informationColor>white</informationColor>
<noticeColor>green</noticeColor>
<warningColor>yellow</warningColor>
<errorColor>red</errorColor>
<criticalColor>lightMagenta</criticalColor>
<fatalColor>lightMagenta</fatalColor>
</cScreen>
<cFile>
<class>FileChannel</class>
<path>logs/application.log</path>
<rotation>1 M</rotation>
<archive>number</archive>
<purgeCount>5</purgeCount>
<formatter>
<class>PatternFormatter</class>
<pattern>%H:%M:%S : %T : [%p] : %t</pattern>
</formatter>
</cFile>
</channels>
<loggers>
<root>
<name></name>
<channel>cFile</channel>
<level>trace</level>
</root>
<main>
<name>main</name>
<channel>cScreen</channel>
<level>trace</level>
</main>
</loggers>
</logging>
登录屏幕并在文件make:
Poco::Logger::get("main").trace(msg);
只记录到make
文件Poco::Logger::get("").trace(msg);
相关文章:
- 为不同配置设置MSVC_RUNTIME_LIBRARY的正确方法是什么
- 无法找到/读取配置文件.conf-FileIOException
- 如何将enable-if与模板参数和参数包一起使用
- 如何将PERF_AMPLE_READ与mmap一起使用
- 如何将两个不同矢量的同一位置的两个元素组合在一起
- 在WSL:configure_file上对config_file的每次调用都失败:配置文件时出现问题
- 如何将C++中的库和头与MinGW一起使用
- 一种在C++中读取TXT配置文件的简单方法
- 将--whole archive链接器选项与CMake和具有其他库依赖项的库一起使用
- 为什么我不能将 rand() 与数组的大小一起使用?
- 要与"if constexpr"一起使用的编译时消息(在预处理器之后)
- 生成MRPT库时cmake配置失败
- 不能将复制初始化与隐式转换的多个步骤一起使用
- 我应该如何获取配置文件的绝对路径与 Windows .exe一起发布?
- 我如何配置我的cmake文件以与Google Test和CTEST一起使用
- 将 boost-di 与配置文件和共享库一起使用
- QT项目在配置文件上崩溃,与发布和调试器一起运行
- 我可以将OpenCV的Release配置与我的应用程序的Debug配置一起使用吗
- Visual Studio 2010 默认属性表似乎在调试和发布配置下都链接在一起,这是怎么回事?
- 无法将splitterChannel与高级xml配置一起使用