c++ - Problems with loggers hierarchy in Poco Logging Framework -


i'm facing problems when using logging framework. have configuration file following:

# core channel logging.channels.c1.class = filechannel logging.channels.c1.path = <somepath>/core.log logging.channels.c1.archive = timestamp logging.channels.c1.times = utc logging.channels.c1.rotation = daily logging.channels.c1.formatter.class = patternformatter logging.channels.c1.formatter.pattern = %y-%m-%d %h:%m:%s %s: [%p] %t  # core logger logging.loggers.l1.name = core logging.loggers.l1.level = information logging.loggers.l1.channel = c1 

my program uses poco::util:serverapplication framework, benefiting subsystems schema. have multiple subsystems, , each 1 stores reference poco::logger object, obtained using poco::logger::get("logger name") method. i'm trying use use log hierarchy, having "core" log, showed in configuration file above, root of logging hierarchy. following code exemplifies i'm doing in each susbsystem:

subsystem1::subsystem1() :    poco::util::subsystem(),          logger_(poco::logger::get("core." + std::string(name()))),         ...  subsystem2::subsystem2() :    poco::util::subsystem(),          logger_(poco::logger::get("core." + std::string(name()))),         ... 

that works logging. it's nice because i've inherited configuration property file, , each subsystem have different poco::message source name, making easy identify subsystem logging entry comes from.

the problem arrives when try change property of instance of logger (for example, subsystem1's logger). if change it's channel's path, instance, changing propagated whole hierarchy. following code demonstrate issue:

poco::logger& subsystem1logger = poco::logger::get("core.subsystem1"); poco::logger& subsystem2logger = poco::logger::get("core.subsystem2"); subsystem1logger.getchannel()->close(); //without this, change channel's   path nothing subsystem1logger.getchannel()->setproperty("path", <someotherpath>/core2.log); // ok, it's changed poco_information(subsystem1logger "some message"); // ok, logs  <someotherpath>/core2.log poco_information(subsystem2logger "some message"); // not ok, logs  <someotherpath>/core2.log instead of  <somepath>/core.log 

i'm confused, because stated in header file of poco::logger class "once logger has been created , has inherited channel , level ancestor, loses connection it. changes level or channel of logger not affect descendants".

by way, root logger (core) affected change.

am missing something? thanks.

poco library version: 1.5.1

i think getting confused between logger , channel.

the loggers core core.subsystem1 core.subsystem2

are attached same channel c1, because copy of core when created.

it's channel c1 changing through logger.getchannel() function.

if loggers attached different channels approach working.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -