ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Setting logging directory per Node in Foxy

asked 2021-05-17 07:44:44 -0500

Hi, is there a way to set up my logger, so that it outputs log files into different directories?

For example, let's say I have a my_node node, and I would like for it to log it's contents to ./ros/logs/my_node/ like

auto logger = rclcpp::get_logger("my_node");
logger.set_logging_directory(path_to_logging_dir/my_node) // (i know this doesn't exist right now, it's just an example)

is there a way to access the logging internals to do that?

I know that spdlog library has basic_file_sink ROS2 uses spdlog underneath, so maybe there is an access to it?

I've seen

https://answers.ros.org/question/3577... but this is per launch file, and I want to separate on my node level, via rclcpp. I have also seen

https://docs.ros.org/en/foxy/Tutorial..., but here the default variables only respond to the main ros directory.

edit retag flag offensive close merge delete

Comments

Or is the encapsulation by launch file the correct way to do things?

Serafadam gravatar image Serafadam  ( 2021-05-17 07:48:50 -0500 )edit

I see an API for getting the log directory, but I don't see one for setting it. https://github.com/ros2/rcl_logging/b...

Maybe there's a way to set the directory in the file rcl_logging_external_initialize()? Even then I think logging affects the whole process, so if an API was added to rclcpp it may affect all nodes in the process.

sloretz gravatar image sloretz  ( 2021-05-17 13:02:52 -0500 )edit

You could try splitting your nodes into individual launch files, and then make a "master" launch file that references the others. Is this something feasible for you to try?

Spectre gravatar image Spectre  ( 2021-05-17 13:14:04 -0500 )edit

After some thinking, I think doing this via launch file seems the cleanest solution for this case.

Serafadam gravatar image Serafadam  ( 2021-05-18 08:48:47 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-05-31 13:20:23 -0500

Spectre gravatar image

It's a bit late, but it looks like this feature has been implemented in the latest ROS2 release, Galactic Geochelone!

Check it out here: ROS2 Galactic, Updates to ROS2, "Ability to Specify Per-Logger Log Levels"

edit flag offensive delete link more

Comments

I'm afraid logging levels don't have much to do in this case

Serafadam gravatar image Serafadam  ( 2021-06-01 03:51:38 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2021-05-17 07:44:44 -0500

Seen: 197 times

Last updated: May 31 '21