Project: datamanagement
Issue DM-2373: Improve logger use in qserv
Qserv logger must be easily configurable. Next technique, based on log4cxx documentation allows to do it easily. Example: In QuerySession.cc, initialize a static logger: {code:c++} namespace lsst { namespace qserv { namespace qproc { LOG_LOGGER QuerySession::_logger = LOG_GET("lsst.qserv.qproc.QuerySession"); {code} then use it in Query session member functions: {code:c++} if (LOG_CHECK_LVL(_logger, LOG_LVL_DEBUG)) { std::ostringstream stream; _showFinal(stream); LOGF(_logger, LOG_LVL_DEBUG, "Query Plugins applied:\n %1%" % stream.str()); } {code} And use log4cxx.property to easily configure, AT RUNTIME, logging for each Qserv module class: {code} # logger for all module will inherit this one log4j.logger.lsst.qserv=ERROR # this could be generalized to all Qserv modules: log4j.logger.lsst.qserv.qproc=INFO # can also be done at the class level for advanced debugging #log4j.logger.lsst.qserv.qproc.QuerySession=DEBUG {code} And then in the log: {code} /home/qserv/qserv-run/2015_03/var/log/qserv-czar.log:0319 17:08:48.786 [0x7f208da93740] DEBUG lsst.qserv.qproc.QuerySession (build/qproc/QuerySession.cc:118) - Query Plugins applied: {code} This proposal is a draft and should be improved before implementing it.
Story points: 8