ros2 / launch

Tools for launching multiple processes and for writing tests involving multiple processes.
Apache License 2.0
117 stars 138 forks source link

Add an option to disable creating log files by the launch system #761

Open ksuszka opened 4 months ago

ksuszka commented 4 months ago

Feature request

Add an option to disable creating log files by the launch system.

Feature description

We deploy a ROS application which uses the launch subsystem using docker containers. We try to follow well known industry guidelines like Heroku's 12-factor app https://12factor.net/logs. This guideline states that the application should not force creating log files but instead it should output log entries using standard streams. This makes a lot of sense, especially if you deploy the application to an embedded device with a flash storage that wears quickly with unnecessary writes.

At the moment is seems that there is no way to disable creating launch.log file as it is created unconditionally in the get_logger function of the launch system: https://github.com/ros2/launch/blob/d9ffd805e3d9ca42fe4dd0019ae095e9eb0d4d72/launch/launch/logging/__init__.py#L350.

Implementation considerations

ksuszka commented 4 months ago

Unfortunately, it seems that the launch system is only the tip of the iceberg. There are various parts of the ROS ecosystem that unconditionally create log files. For example, in theory there is a possibility to disable creating log files in rclcpp/rclpy by adding --disable-external-lib-logs argument to the init function, but there are places like ros2 service where you cannot add this argument, so every successful call to ros2 service creates a file on disk.

We were able to remove creation of most of the log files by adding custom extensions to the launch system:

but it is more a workaround than a proper solution and it doesn't solve the ros2 service case.

At this moment I think that the simplest solution would be to add to rclc/rclcpp/rclpy support for handling an environment variable like RCUTILS_USE_EXTERNAL_LIB_LOGS which could be set globally in the environment. And similar thing would be needed in the launch subsystem.