You must take care of all the receivers and recreate them in the pthread_atfork handler in the child process_. That is, the add_console_log or add_file_log return a boost::shared_ptr to the receiver. Reset, and initialize again.
... boost::shared_ptr< sinks::synchronous_sink< sinks::text_ostream_backend > > console_sink = logging::add_console_log(); ... void fork_child_handler(void) { console_sink = logging::add_console_log(); return; }
Take care that a fork can leave more than just broken logs. Stay away from multithreading and fork all means (its some irony that the pthread library provides a fork handler that you want to avoid if there are threads ...).
schroder
source share