Summary
The ROS PMC has approved backporting an improved log file flushing behavior to ROS 2 Humble. This change will be included in an next Humble sync and affects how rcl_logging_spdlog flushes log data to the filesystem.
What’s Changing?
Previously, rcl_logging_spdlog did not explicitly configure flushing behavior, which could result in:
- Missing log messages when an application crashes
- Empty or incomplete log files during debugging sessions
After this update, the logging behavior will:
- Flush log files every 5 seconds (periodic flush)
- Immediately flush on ERROR level messages (flush on error)
This provides a much better debugging experience, especially when investigating crashes or unexpected application terminations.
Compatibility
API/ABI compatible — No rebuild of your packages is required
Behavior change — Log files will be flushed more frequently
How to Revert to the Old Behavior
If you need to restore the previous flushing behavior (no explicit flushing), you can set the following environment variable:
export RCL_LOGGING_SPDLOG_EXPERIMENTAL_OLD_FLUSHING_BEHAVIOR=1
Note: This environment variable is marked as EXPERIMENTAL and is intended as a temporary measure. It may be removed in future ROS 2 releases when full logging configuration file support is implemented. Please do not rely on this variable being available in future versions.
Related Links
- Original PR (rolling): https://github.com/ros2/rcl_logging/pull/95
- Backport PR (humble): change flushing behavior for spdlog log files, and add env var to use old style (no explicit flushing) (backport #95) by mergify[bot] · Pull Request #136 · ros2/rcl_logging · GitHub
- Future logging configuration plans: [rolling] Update maintainers - 2022-11-07 by audrow · Pull Request #96 · ros2/rcl_logging · GitHub
Questions or Concerns?
If you experience any issues with this change or have feedback, please:
- Comment on this thread
- Open an issue at GitHub · Where software is built
Thanks,
Tomoya