Asynchronous thread-safe logging in C++

后端 未结 5 501
南方客
南方客 2021-02-04 04:04

I\'m looking for a way to do asynchronous and thread-safe logging in my C++ project, if possible to one file. I\'m currently using cerr and clog for th

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-04 05:09

    Have you considered using a log library.

    There are several available, I discovered Pantheios recently and it really seems to be quite incredible.

    It's more a front-end logger, you can customize which system is used. It can interact with ACE or log4cxx for example and it seems really easy to use and configure. The main advantage is that it use typesafe operators, which is always great.

    If you just want a barebone logging library:

    • ACE
    • log4c*
    • Boost.Log

    Pick any :)

    I should note that it's possible to implement lock-free queues in C++ and that they are great for logging.

提交回复
热议问题