Boost.Log does not support fork(). This is kind of unbelievable, but a ticket comment describes a workaround:
[..] so for now it's up to users to reinitialize the library at fork. You can use pthread_atfork to do such reinitialization.
Thus my question: how exactly do I re-initialize Boost.Log after a fork()?
Code example much appreciated.
You have to take care of all the sinks, and recreate them in the
pthread_atfork
handler in the child process_. I.e. theadd_console_log
oradd_file_log
functions return aboost::shared_ptr
to the sink. Reset that, and initialize it again.Take care, that
fork
may leave more things behind than just broken log sink. Stay away from multi-threading andfork
by all means (its some irony that pthread library provides the handler for fork, which you want to avoid if there are threads ...).