Boost C++ Libraries: Ticket #12402: knowing the current filename used by a boost.log text_file_backend https://svn.boost.org/trac10/ticket/12402 <p> I am trying to use the Boost.Log library and am quite pleased with it so far. (I am transitioning from log4cxx.) Before getting into the details, let me say why I am asking this question. </p> <ol><li>I need to populate a status line to tell an administrator the path to the current output log file. </li><li>On shutdown (and at any point really), I need to provide a summary that points a user to the path of the last output log file. </li></ol><p> As far as I can tell I am unable to meet either of these requirements with the 1.60 implementation of the Boost.Log <code></code>text_file_backend<code></code>. Regarding the first requirement the <code></code>text_file_backend<code></code> provides open and close handler methods, but those use a stream argument and they are intended to be used to write header and footer text to the output stream when a file is opened or closed. But I need to know the *filename* of the stream that is opened. </p> <p> Regarding 2, the file_collector <code></code>store_file<code></code> method takes a source path. But I need to know the destination path not the source path. I do not see anything that exposes the final destination where the collector has stored my files. </p> <p> As a user of Boost.Log 1.60 is there a way to meet either of these requirements through the current API? If not, any suggestions on the best way to proceed? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12402 Trac 1.4.3 Andrey Semashev Sat, 20 Aug 2016 00:43:38 GMT <link>https://svn.boost.org/trac10/ticket/12402#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12402#comment:1</guid> <description> <p> There is no API to obtain the current file name. You could try implementing your own log file collector. Basically, the collector implemented in Boost.Log does not rename the file, it only moves it to the target directory, which you specify when you create the collector. So by implementing <code>collector::store_file</code> you should be able to know the full path to the last rotated log file. The currently written file name is inaccessible, you'll have to patch the library to change that. </p> </description> <category>Ticket</category> </item> <item> <author>Philip Miller <philip.miller@…></author> <pubDate>Mon, 22 Aug 2016 13:57:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12402#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12402#comment:2</guid> <description> <p> I have modified text_file_backend so that it meets my requirements. I did this by: </p> <ol><li>adding to the open and close handler a string argument for the filename of the stream; the stream filename is readily available from m_pImpl-&gt;m_FileName where the open and close handlers are called by text_file_backend::consume and text_file_backend::close_file. </li><li>adding to the collector interface a set_store_handler callback method that the file_collector implements so it may use the callback in its implementation of the store_file method. </li></ol><p> Right now I have put these changes in a copy of text_file_backend that I have incorporated into the source code of my local project. If you are interested, I can put these changes into a pull request for Boost.Log. As far as I can see, the changes are quite small and seem to fit in well with your text_file_backend implementation. Unfortunately, change (1), modifies the current text_file_backend open and close _handler_type types, so it will affect compatibility. I am not sure how, if at all, you want to deal with API changes. </p> <p> I do, however, think the improved functionality my changes provide are important. Without these changes, I cannot meet either of my requirements. I would like to get this functionality into a future Boost.Log release as I do not like either choice of maintaining my own hacked copy of text_file_backend, or my own distribution of boost. </p> <p> Thanks for all of your effort on Boost.Log! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Sun, 16 Oct 2016 14:55:17 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/12402#comment:3 https://svn.boost.org/trac10/ticket/12402#comment:3 <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> Added a method to obtain the current log file name from the text file sink backend in <a class="ext-link" href="https://github.com/boostorg/log/commit/a74e9d4a74dabe912f5eeeac3b7a987ad1c5b2e1"><span class="icon">​</span>https://github.com/boostorg/log/commit/a74e9d4a74dabe912f5eeeac3b7a987ad1c5b2e1</a>. </p> Ticket