2

I would like to make the output of BOOST_LOG_TRIVIAL configurable, ie remove the timestamp and/or threadid and/or severity. Current output is eg this

[2016-01-17 17:26:22.609294] [0x00007fc4b8dbd840] [fatal] "my MSG"

What would be the easiest way to achieve this while still using trivial logging and minimal extra? In addition, maybe change the formatting of timestamp or provide a name of thread instead of thread id.

Thanks, filimon

filimon
  • 61
  • 4

1 Answers1

2

You can achieve this by creating a sink with a suitable formatter. The process is described in the Tutorial (use add_console_log instead of add_file_log if you want to keep sending logs to the console). You may also need to add a few common attributes, such as timestamps, if you want them in your output. After setting up the sink all logs produced by BOOST_LOG_TRIVIAL will be directed to that sink.

Andrey Semashev
  • 10,046
  • 1
  • 17
  • 27