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

Change rospy node log level while running

asked 2011-04-22 04:59:26 -0500

baxelrod gravatar image

updated 2021-12-06 13:37:24 -0500

130s gravatar image

Is there any way to change a rospy node's log level while it is running? http://www.ros.org/wiki/rospy/Overview/Logging says that you must pass in a parameter to rospy.init_node(), which means you need to kill and restart the node...

Also, I am curious why rxloggerlevel doesn't work for python nodes.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
2

answered 2021-12-02 08:37:43 -0500

JeremyRoy gravatar image

Not much hacking is required to accomplish this:

import rospy
import logging

def set_rospy_log_lvl(log_level):
    logger = logging.getLogger('rosout')
    logger.setLevel(rospy.impl.rosout._rospy_to_logging_levels[log_level])

You can use this function wherever you want (after rospy.init()) to change the log level. Works in Melodic.

Example usage:

rospy.init("my_node", anonymous=True)
set_rospy_log_lvl(rospy.DEBUG)
edit flag offensive delete link more
6

answered 2011-04-22 08:00:11 -0500

kwc gravatar image

You currently can't do this in rospy without some severe internal API hacking. This would make a good feature request ticket (or patch).

rxloggerlevel works against an API that was developed solely for roscpp. I've been meaning to add it to rospy, but the API needs some cleanup and it's been lower priority.

edit flag offensive delete link more
1

answered 2021-12-07 15:53:49 -0500

GeorgNo gravatar image

You can also use rosrun rqt_logger_level rqt_logger_level

edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-04-22 04:59:26 -0500

Seen: 1,613 times

Last updated: Dec 07 '21