3

boost logging explicitly says it is not.

easylogging++ looks like it sets up extern'ed static state that might be trouble after a fork.

Requirements: log rolling after a certain size, support of logging levels, thread-safe.

I'd be happy with something that even needed to be reinitialized after forking.

1 Answer 1

2

I was successfully using spdlog in such scenario. Just initialize logger after calling fork.

https://github.com/gabime/spdlog

2
  • 1
    Welcome aboard. this is a good answer (+1), but it is not very helpful. Normally, we ask you to explain why your recommendation meets the OP's needs. In this case, with the main emphasis being on Forking, I note that the page mentions benchmarking with a number of threads, so this should suit the OP's requirements.
    – Mawg
    Commented Jan 8, 2018 at 12:22
  • Actually spdlog is not fork-safe. The library employs localtime_r for formatting under the hood, which is not fork-safe. Even if you initialize a new logger in the child process, there is a global mutex in localtime_r implementation, which can be copied into child process in locked state (and from times to times it occurs). I'm currently using the library and trying to workaround the problem.
    – nicolai
    Commented May 22, 2020 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.