Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RCL_LOGGING_DISABLE_FILE_WRITING to disable file logging #106

Open
wants to merge 1 commit into
base: rolling
Choose a base branch
from

Conversation

mganeff
Copy link

@mganeff mganeff commented Oct 25, 2023

Add ability to completely disable file writing in rcp_logging_spdlog by setting the environment variable:

RCL_LOGGING_DISABLE_FILE_WRITING=1

@clalancette
Copy link
Contributor

So I have to say that this is a weird feature.

The entire purpose of the rcl_logging layer is to write to disk. Writing to the console and /rosout are done at different layers. And we already have a way to disable writing to disk at the RCL layer: http://docs.ros.org/en/rolling/Concepts/Intermediate/About-Logging.html#node-creation

So with all of that in mind, can you please explain the use-case for this?

@mganeff
Copy link
Author

mganeff commented Oct 26, 2023

I understand that I can disable logging for a certain node by using the disable-external-lib-logs argument

ros2 run foo bar --ros-args --disable-external-lib-logs

I am however unable to find a working solution for disabling logging for nodes started with ros2 launch

  • ros2 launch launch_file.launch (xml based)
  • ros2 launch launch_file.launch.py

In our environment we spawn multiple nodes (20+). For testing we would like to create the logs but for deployment we would like to disable them, hence the env variable to be able to disable/enable external logging features for all nodes :)

@clalancette
Copy link
Contributor

I am however unable to find a working solution for disabling logging for nodes started with ros2 launch

You should be able to declare a launch argument for that, and pass it into all of the nodes. You can see some documentation about that in http://docs.ros.org/en/rolling/Tutorials/Intermediate/Launch/Using-ROS2-Launch-For-Large-Projects.html or http://docs.ros.org/en/rolling/Tutorials/Intermediate/Launch/Using-Substitutions.html

@mganeff
Copy link
Author

mganeff commented Oct 27, 2023

Thanks for the answer. I managed to disable logging for all my nodes by adjusting the launch files:

ros2 launch .xml:

<node pkg="foo" exec="bar" output="screen" args="--ros-args --disable-external-lib-logs"/>

ros2 launch .py:

ld.add_action(
   Node(
       package="foo",
       executable="bar",
       output="screen",
       emulate_tty=True,
       arguments=["--ros-args", "--disable-external-lib-logs"],
   )
)

ros2 run:

ros2 run foo bar --ros-args --disable-external-lib-logs

I was wondering if there is an environment variable such like DEFAULT_ROS_ARGS which I could extend with --disable-external-lib-logs to be able to toggle logging on/off for our nodes.

@mganeff
Copy link
Author

mganeff commented Nov 3, 2023

Despite the parameter disable-external-lib-logs, still logs are generated in ~/.ros/log. Each launched node gets a directory with a launch.log. Is there a way to disable this?

@clalancette
Copy link
Contributor

Despite the parameter disable-external-lib-logs, still logs are generated in ~/.ros/log. Each launched node gets a directory with a launch.log. Is there a way to disable this?

That's the logging coming from launch, rather than from the node itself. I think if you remove output from your launch statements, that will stop happening.

Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think even if we had a feature something like this, doing this in the specific implementation is not the right place to do that.

I was wondering if there is an environment variable such like DEFAULT_ROS_ARGS which I could extend with --disable-external-lib-logs to be able to toggle logging on/off for our nodes.

no i don't think so. for me this can be scary giant switch if we have it. because we can add remapping, namespace, names, parameters and logging configuration via arguments. i think those arguments are meant to be applied to the Node, not any Node. So this could possibly lead to the problem for user.

@cfveeden cfveeden mentioned this pull request Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants