How to change log directory on ROS2 Foxy?
Both variables ROSHOME and ROSLOG_DIR were empty. I set them both to the desired folder. Yet logs are being saved at the default folder ~/.ros/logs
Asked by apoorvcn47 on 2021-05-13 12:05:24 UTC
Answers
I haven't seen any references to changing the log file directory, but there are two options:
- Use a logging configuration file
- Changing the logger used / changing whether rosout or stdout are used.
On the "ROS2 Design" blog there is a pretty nice overview of ROS2 command-line arguments: here
If you were able to change a log file directory I would expect there to be a ros2 CLI argument, but on that page there is none. However as I mentioned above it does look like there is an unexplained "config file"
For external logging configuration, use
--log-config-file path/to/file.config
and a log configuration file.
The bad news is that I wasn't the first one to wonder about the lack of documentation for this config file: ROS2 Answers, "Documentation for ros2 log config?"
The poster received no response, and that was posted this January so it's fairly "recent".
I was also able to find another reference to logging from July 2019 regarding logging to a specific file: here
(User "alsora", July 22, 2019) By default, the messages will be also logged to a specific topic, named
rosout
. (This behavior can be disabled using the parameter__log_disable_rosout:=true
) So you can listen to them usingros2 topic echo /rosout
. An alternative is to userqt
which has plugins for reading and filtering logs
Asked by Spectre on 2021-05-13 15:20:26 UTC
Comments