Boost C++ Libraries: Ticket #10061: boost::log (boost logging): BOOST_LOG_FUNCTION works only in main thread https://svn.boost.org/trac10/ticket/10061 <p> Consider the following function: </p> <pre class="wiki">void thread() { BOOST_LOG_FUNCTION(); while(true) { // Create log entry } } </pre><p> If I just call "thread()" within main() as a function my log entries created in "thread()" look as expected: </p> <pre class="wiki">[void __cdecl thread(void) (c:\...\maintest.cpp:16)] </pre><p> However if you use "thread()" within main() as a real thread: </p> <pre class="wiki"> boost::thread t(thread); </pre><p> the appropriate log-entry containing the scope is empty: </p> <pre class="wiki">[] </pre><p> Code snippet: </p> <pre class="wiki">keywords::format = expr::stream &lt;&lt; "[" &lt;&lt; expr::format_named_scope("Scope", keywords::format = "%n (%f:%l)")&lt;&lt; "] " </pre><p> I do not understand this, since the appropriate values <strong><span class="underline">FUNCTION</span></strong> and <strong><span class="underline">FUNCSIG</span></strong> are always available when manually printed. Operating system: Windows 7. I posted the issue without a solution on stackoverflow a few months ago so that I assume it is a bug: </p> <p> <a class="ext-link" href="http://stackoverflow.com/questions/19893181/boostlog-boost-logging-boost-log-function-only-works-in-main-thread"><span class="icon">​</span>http://stackoverflow.com/questions/19893181/boostlog-boost-logging-boost-log-function-only-works-in-main-thread</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10061 Trac 1.4.3 Andrey Semashev Tue, 20 May 2014 11:24:11 GMT <link>https://svn.boost.org/trac10/ticket/10061#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10061#comment:1</guid> <description> <p> In order the scope names to be present in the output, the named_scope attribute has to be present for the thread that emits the log record. That is, either named_scope has to be added as a global attribute (i.e. with add_global_attribure) or added as a thread-specific attribute in every thread (e.g. by calling add_thread_attribute somewhere early in the thread routine). Please verify that your code does this. </p> <p> If your code adds the attribute properly then could you please provide a small compilable example so that I'm able to reproduce the problem. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 20 May 2014 11:37:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10061#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10061#comment:2</guid> <description> <p> add_global_attribure solved the problem. I am sorry for bothering you. The logging library is really a beautiful piece of software. However, the documentation should be improved. It is very hard to obtain desired information. Keep up the great work! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Tue, 20 May 2014 12:05:33 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/10061#comment:3 https://svn.boost.org/trac10/ticket/10061#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">invalid</span> </li> </ul> <p> I recommend reading the <a href="http://www.boost.org/doc/libs/1_55_0/libs/log/doc/html/log/design.html">Design section</a> in the docs, it explains different types of attributes and gives a good insight on the library architecture. With that kind of knowledge it's easier to explore the library further. </p> Ticket