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
BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT, BOOST_LOG_ATTRIBUTE_KEYWORD
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
empty.
Would you please clarify following questions:
(1) Will it be a problem to keep the
BOOST_LOG_ATTRIBUTE_KEYWORD(severity, "Severity",
::LibraryGlobalServerityLevel_t) and
BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(mGlobalLogger,
boost::log::sources::severity_logger_mt<::LibraryGlobalServerityLevel_t>)
in a header file Log.hpp where many sources include the header file
Log.hpp?
(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