Boost C++ Libraries: Ticket #12369: In boost::log, how to print extra header line when file rotation/rollover https://svn.boost.org/trac10/ticket/12369 <p> I have an extra header line to be written to log file (csv format). It has a special format. How to write this header line every time when log file is rotated/rollover? Thank you. My code is like: </p> <blockquote> <p> const char *logHeaders = "timestamp,thread,client,message"; </p> </blockquote> <blockquote> <p> ... </p> </blockquote> <blockquote> <p> boost::shared_ptr&lt; sinks::text_file_backend &gt; backend = </p> <blockquote> <p> boost::make_shared&lt; sinks::text_file_backend &gt;( </p> <blockquote> <p> logging::keywords::file_name = "myfile_%5N.csv" </p> </blockquote> <p> logging::keywords::rotation_size = 5 * 1024 * 1024, </p> <blockquote> <p> logging::keywords::time_based_rotation = sinks::file::rotation_at_time_point(12, 0, 0), ); </p> </blockquote> </blockquote> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12369 Trac 1.4.3 Andrey Semashev Tue, 02 Aug 2016 15:49:30 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/12369#comment:1 https://svn.boost.org/trac10/ticket/12369#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">invalid</span> </li> </ul> <p> See open/close handlers. </p> <p> <a href="http://www.boost.org/doc/libs/1_61_0/libs/log/doc/html/log/detailed/sink_backends.html#log.detailed.sink_backends.text_file">http://www.boost.org/doc/libs/1_61_0/libs/log/doc/html/log/detailed/sink_backends.html#log.detailed.sink_backends.text_file</a> </p> Ticket anonymous Tue, 02 Aug 2016 21:07:42 GMT <link>https://svn.boost.org/trac10/ticket/12369#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12369#comment:2</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/12369#comment:1" title="Comment 1">andysem</a>: </p> <blockquote class="citation"> <p> See open/close handlers. </p> <p> <a href="http://www.boost.org/doc/libs/1_61_0/libs/log/doc/html/log/detailed/sink_backends.html#log.detailed.sink_backends.text_file">http://www.boost.org/doc/libs/1_61_0/libs/log/doc/html/log/detailed/sink_backends.html#log.detailed.sink_backends.text_file</a> </p> </blockquote> <p> Hi, The example in that link works fine for narrow char. I am using wide char header line. But I can not find the wide char version of text_file_backend::stream_type. Which one shall I use? Thank you. </p> <p> Your example: </p> <pre class="wiki">void write_header(sinks::text_file_backend::stream_type&amp; file) { file &lt;&lt; "&lt;?xml version=\"1.0\"?&gt;\n&lt;log&gt;\n"; } ... sink-&gt;locked_backend()-&gt;set_open_handler(&amp;write_header); </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Tue, 02 Aug 2016 22:51:47 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12369#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12369#comment:3</guid> <description> <p> There is no wide character version as the sink backend already operates on converted characters. If you have national characters in your header/footer you'll have to perform character conversion yourself. </p> </description> <category>Ticket</category> </item> </channel> </rss>