Boost C++ Libraries: Ticket #11719: Create a log file only if some data is written to it https://svn.boost.org/trac10/ticket/11719 <p> I am creating a log file using </p> <p> src::severity_logger&lt; severity_level &gt; m_DbLogger; logging::add_file_log ( </p> <blockquote> <p> keywords::auto_flush = true, keywords::file_name = m_Settings.LogFileSQL + "_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> It creates a log file before any log goes into it. I want to have that log file ONLY IF some data is written into it. If no log goes into it we dont want to see that log file. </p> <p> Please suggest a solution for it. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11719 Trac 1.4.3 Andrey Semashev Mon, 12 Oct 2015 12:34:05 GMT severity changed https://svn.boost.org/trac10/ticket/11719#comment:1 https://svn.boost.org/trac10/ticket/11719#comment:1 <ul> <li><strong>severity</strong> <span class="trac-field-old">Showstopper</span> → <span class="trac-field-new">Problem</span> </li> </ul> <p> The file is created when log records are passed to the sink. If that is not what happens in your case, please provide a minimal compilable code sample that reproduces the problem. </p> Ticket Andrey Semashev Thu, 15 Oct 2015 18:11:29 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11719#comment:2 https://svn.boost.org/trac10/ticket/11719#comment:2 <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">worksforme</span> </li> </ul> Ticket