Boost logo

Boost :

Subject: Re: [boost] Boost log issues and workarounds
From: hh h (jupiter.hce_at_[hidden])
Date: 2019-01-20 07:36:32

Hi Andrey,

Sorry, I was excited too earlier. In my simple test program, it was
working well, but the massive changes of replacing google log by boost
log did not go well. That could be due to the complicate real
application structure.

I have a Log class to wrap the boost log built into a library, the
and the #define LOG are all defined in Log.hpp, that should be fine,
right? The boost log initial function is implemented in the Log class
in Log.cpp. The log initial function was called just once in an
application base class and remain in the memory until the application
exits. First, it got Segmentation fault (core dumped), after changing
boost::log::core::get()->add_global_attribute() and
boost::log::core::get()->add_thread_attribute() to
boost::log::core::get()->add_thread_attribute in the initial function
of Log.cpp, it fixed the Segmentation fault, but it did not write
anything to the log file in /tmp/log/network.log, the log file is

Would you please clarify following questions:

(1) Will it be a problem to keep the
::LibraryGlobalServerityLevel_t) and
in a header file Log.hpp where many sources include the header file

(2) I think that the boost log initialization should be called once
even in multi threading program to share the same log, is it correct?

(3) What are different between add_global_attribute and
add_thread_attribute? I thought since I use GLOBAL_LOGGER, I should
use the add_global_attribute, why it got Segmentation fault?

(4) What could I be missing that the log file is empty? I am writing
the log file currently to the /tmp which won't cause any permission
issues. I tried both static calling boost::log::add_file_log(..) and
shared pointer boost::shared_ptr<FileSink_t> sink(new FileSink_t(...)
in the log initial function, it did not make any difference, none of
it works.

(5) Currently I built it using dynamic link, can it use static link?
What will be the build macro for static link?

Boost list run by bdawes at, gregod at, cpdaniel at, john at