Boost C++ Libraries: Ticket #11720: Problem with 2 loggers in one class https://svn.boost.org/trac10/ticket/11720 <p> Hello, </p> <p> i am using src::severity_logger&lt; severity_level &gt; and facing some issue. Here is the issue and code - </p> <p> I have 2 loggers in a class as class members </p> <p> class A { src::severity_logger&lt; severity_level &gt; m_DbLogger; src::severity_logger&lt; severity_level &gt; m_DiagnosticsLogger; </p> <p> } </p> <p> 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. </p> <p> i am usign following code - </p> <p> logging::add_file_log ( </p> <blockquote> <p> keywords::auto_flush = true, keywords::file_name = mylogfile + ".log", keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0), keywords::format = ( </p> <blockquote> <p> boost::log::expressions::stream &lt;&lt; boost::log::expressions::format_date_time&lt; boost::posix_time::ptime &gt;("<a class="missing wiki">TimeStamp</a>", "%Y-%m-%d %H:%M:%S") &lt;&lt; ": [" &lt;&lt; boost::log::expressions::attr&lt; severity_level &gt;("Severity") &lt;&lt; "] " &lt;&lt; boost::log::expressions::smessage </p> </blockquote> <p> ) </p> </blockquote> <p> ); </p> <p> logging::add_file_log ( </p> <blockquote> <p> 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 = ( </p> <blockquote> <p> boost::log::expressions::stream &lt;&lt; boost::log::expressions::format_date_time&lt; boost::posix_time::ptime &gt;("<a class="missing wiki">TimeStamp</a>", "%Y-%m-%d %H:%M:%S") &lt;&lt; ": [" &lt;&lt; boost::log::expressions::attr&lt; severity_level &gt;("Severity") &lt;&lt; "] " &lt;&lt; boost::log::expressions::smessage </p> </blockquote> <p> ) </p> </blockquote> <p> ); </p> <p> 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 - </p> <p> LOG_MAIN_INFO_EX(m_DbLogger, "/* try #" &lt;&lt; i &lt;&lt; " " &lt;&lt; (ws.elapsed() / 1000) &lt;&lt; " [ms]*/ " &lt;&lt; statement); </p> <p> where macro is defined as - #define LOG_MAIN_INFO_EX(logger, _str) BOOST_LOG_SEV(logger, info) &lt;&lt; _str; </p> <p> In this case the log goes in both file and not just in mylogfile.log but also in mylogfile_diagnostics.log file as well. </p> <p> I want the log to go in just 1 file ie in mylogfile.log. </p> <p> And when i call LOG_MAIN_ERROR_EX(m_DiagnosticsLogger, "Statement : " &lt;&lt; statement); where macro is defined as - #define LOG_MAIN_ERROR_EX(logger, _str) BOOST_LOG_SEV(logger, error) &lt;&lt; _str; </p> <p> in this case i want this log to go only in mylogfile_diagnostics.log and not in mylogfile.log </p> <p> Basically i want to connect following block to m_DbLogger logging::add_file_log ( </p> <blockquote> <p> keywords::auto_flush = true, keywords::file_name = mylogfile + ".log", keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0), keywords::format = ( </p> <blockquote> <p> boost::log::expressions::stream &lt;&lt; boost::log::expressions::format_date_time&lt; boost::posix_time::ptime &gt;("<a class="missing wiki">TimeStamp</a>", "%Y-%m-%d %H:%M:%S") &lt;&lt; ": [" &lt;&lt; boost::log::expressions::attr&lt; severity_level &gt;("Severity") &lt;&lt; "] " &lt;&lt; boost::log::expressions::smessage </p> </blockquote> <p> ) </p> </blockquote> <p> ); </p> <p> and want to connect following bloack to m_DiagnosticsLogger logging::add_file_log ( </p> <blockquote> <p> 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 = ( </p> <blockquote> <p> boost::log::expressions::stream &lt;&lt; boost::log::expressions::format_date_time&lt; boost::posix_time::ptime &gt;("<a class="missing wiki">TimeStamp</a>", "%Y-%m-%d %H:%M:%S") &lt;&lt; ": [" &lt;&lt; boost::log::expressions::attr&lt; severity_level &gt;("Severity") &lt;&lt; "] " &lt;&lt; boost::log::expressions::smessage </p> </blockquote> <p> ) </p> </blockquote> <p> ); </p> <p> Please update me asap. Thanks, Parikshit </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11720 Trac 1.4.3 Andrey Semashev Tue, 13 Oct 2015 08:59:11 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11720#comment:1 https://svn.boost.org/trac10/ticket/11720#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Please, ask questions on <a class="missing wiki">StackOverflow</a>. This tracker is for bug reports. </p> <p> You need to use attributes (channels) and filters to achieve that. See <a class="ext-link" href="http://stackoverflow.com/questions/32981702/is-there-a-way-to-implement-multiple-independent-logging-systems-with-boost-log"><span class="icon">​</span>this answer</a>. </p> Ticket