Boost.log does not print common attributes

63 Views Asked by At

I am trying to make boost logger print LineID, TimeStamp, ProcessID, and ThreadID using add_common_attributes().

void initLogger()
{
  using namespace boost::log;
  add_file_log
  (
    keywords::file_name = "logfile.log",
    keywords::rotation_size = 10 * 1024 * 1024,   //bytes
    keywords::auto_flush = true
  );
  add_console_log(std::cout);
  core::get()->set_filter(trivial::severity >= trivial::trace);
  add_common_attributes();
}

But it does not want to do it. I can guarantee that initLogger() is called at the beginning of the programm.
Using logger like this:

BOOST_LOG_TRIVIAL(warning) << "Skipping event";

I get output:

Skipping event

Same in the logfile.log
I tried to use format keyword and still got same output.

add_file_log
  (
    keywords::file_name = "logfile.log",
    keywords::rotation_size = 10 * 1024 * 1024,   //bytes
    keywords::auto_flush = true,
    keywords::format = "%TimeStamp% (%LineID%) <%Severity%>: %Message%"
  );

I am really feel hopeless right now because i don't know what to do.
Boost version: 1.74.0 Building in debug mode using cmake and g++.
g++ (Debian 10.2.1-6) 10.2.1
Headers are

#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/utility/setup/console.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/trivial.hpp>
0

There are 0 best solutions below