[Boost-bugs] [Boost C++ Libraries] #11720: Problem with 2 loggers in one class

Subject: [Boost-bugs] [Boost C++ Libraries] #11720: Problem with 2 loggers in one class
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-10-13 05:42:48


#11720: Problem with 2 loggers in one class
--------------------------------+---------------------
 Reporter: parikshit.nangre@… | Owner: andysem
     Type: Support Requests | Status: new
Milestone: To Be Determined | Component: log
  Version: Boost 1.59.0 | Severity: Problem
 Keywords: |
--------------------------------+---------------------
 Hello,

 i am using src::severity_logger< severity_level > and facing some issue.
 Here is the issue and code -

 I have 2 loggers in a class as class members

 class A
 {
 src::severity_logger< severity_level > m_DbLogger;
 src::severity_logger< severity_level > m_DiagnosticsLogger;

 }

 i want to use 2 loggers, m_DbLogger for logs related to stored procedures
 and
 m_DiagnosticsLogger to log if any error occured while executing some
 stored procedure.

 i am usign following code -


 logging::add_file_log
 (
         keywords::auto_flush = true,
         keywords::file_name = mylogfile + ".log",
         keywords::time_based_rotation =
 sinks::file::rotation_at_time_point(0, 0, 0),
         keywords::format =
         (
                 boost::log::expressions::stream
                 << boost::log::expressions::format_date_time<
 boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d %H:%M:%S")
                 << ": [" << boost::log::expressions::attr< severity_level
>("Severity")
                 << "] " << boost::log::expressions::smessage
         )
 );

 logging::add_file_log
 (

         keywords::auto_flush = true,
         keywords::file_name = mylogfile + "_diagnostics.log",
         keywords::time_based_rotation =
 sinks::file::rotation_at_time_point(0, 0, 0),
         keywords::format =
         (
                 boost::log::expressions::stream
                 << boost::log::expressions::format_date_time<
 boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d %H:%M:%S")
                 << ": [" << boost::log::expressions::attr< severity_level
>("Severity")
                 << "] " << boost::log::expressions::smessage
         )
 );

 i want to use mylogfile + ".log" for m_DbLogger and want to use mylogfile
 + "_diagnostics.log" for m_DiagnosticsLogger
 but when try to log with -

 LOG_MAIN_INFO_EX(m_DbLogger, "/* try #" << i << " " << (ws.elapsed() /
 1000) << " [ms]*/ " << statement);

 where macro is defined as -
 #define LOG_MAIN_INFO_EX(logger, _str) BOOST_LOG_SEV(logger, info) <<
 _str;

 In this case the log goes in both file and not just in mylogfile.log but
 also in mylogfile_diagnostics.log file as well.


 I want the log to go in just 1 file ie in mylogfile.log.

 And when i call LOG_MAIN_ERROR_EX(m_DiagnosticsLogger, "Statement : " <<
 statement); where macro is defined as -
 #define LOG_MAIN_ERROR_EX(logger, _str) BOOST_LOG_SEV(logger, error) <<
 _str;

 in this case i want this log to go only in mylogfile_diagnostics.log and
 not in mylogfile.log

 Basically i want to connect following block to m_DbLogger
 logging::add_file_log
 (
         keywords::auto_flush = true,
         keywords::file_name = mylogfile + ".log",
         keywords::time_based_rotation =
 sinks::file::rotation_at_time_point(0, 0, 0),
         keywords::format =
         (
                 boost::log::expressions::stream
                 << boost::log::expressions::format_date_time<
 boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d %H:%M:%S")
                 << ": [" << boost::log::expressions::attr< severity_level
>("Severity")
                 << "] " << boost::log::expressions::smessage
         )
 );

 and want to connect following bloack to m_DiagnosticsLogger
 logging::add_file_log
 (

         keywords::auto_flush = true,
         keywords::file_name = mylogfile + "_diagnostics.log",
         keywords::time_based_rotation =
 sinks::file::rotation_at_time_point(0, 0, 0),
         keywords::format =
         (
                 boost::log::expressions::stream
                 << boost::log::expressions::format_date_time<
 boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d %H:%M:%S")
                 << ": [" << boost::log::expressions::attr< severity_level
>("Severity")
                 << "] " << boost::log::expressions::smessage
         )
 );

 Please update me asap.
 Thanks,
 Parikshit

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11720>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC