we are looking for a logging solution that is going to be long term supported and that is, as a bonus, compatible with ROS2.

I would like to know is this is possible to:

  1. Create a package using spdlog
  2. Create ros package wrapping up the first one.
  3. Forward the logs from the 1rst package the second one so all logs appear in the ROS::logger at the end.

Do you think it's feasible? Thanks


2 Answers 2


spdlog is already used in ROS 2 for logging under the hood, see here. So the long-term support is there as long as someone maintains it (if the default backend is changed over time).

If I understood you correctly, you want to use spdlog in an project that does not need ROS 2 and then create wrapper around it to create a ROS 2 package. Now when you use the ROS 2 package, all logs (defined via spdlog::debug/SPDLOG_DEBUG from the underlying project or RCLCPP_DEBUG from the ROS 2 wrapper) should appear as they would if all logs were created in a ROS 2 style.
According to the Logging and logger configuration concept it is not so easy because logging involves several "stages" (subsystem of different libraries). You will probably have to redirect your spdlog log message through the rcl so that it is treated as a ROS 2 log message (publishing via console, file and network).

  • $\begingroup$ Thank you very much for your answer, I will try to investigate further these concepts. $\endgroup$
    – Rextab
    Oct 31, 2023 at 13:22

Q1 and Q2:


Have a look at the rcl_logging_spdlog package (which implements the rcl_logging_interface using spdlog).

If you check its CMakeLists.txt, you will see how it finds spdlog and how it links with spdlog.


Not just like that.

The ROS spdlog backend opens a logfile (per process!) and writes log messages to it, but there is no support to send extra log messages from some other source to that same log file.

Some possible ideas:

  • Write your own implementation of the rcl_logging_interface with the same functionality as the default rcl_logging_spdlog package, but which has extra functionality to receive the extra log messages and write them to that file,

  • Use the /rosout log output instead, publish the extra log messages to that same topic and have a listener write that output to a file (I think you can use ros2 bag for that).


For a code walkthrough wrt. the rclcpp logging system, see here.

  • $\begingroup$ Thank you for your quick response! this much appreciated! It seems spdlog is at least supported for now. And may seem a good fit for us. $\endgroup$
    – Rextab
    Oct 31, 2023 at 13:19

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.