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

Revision history [back]

click to hide/show revision 1
initial version

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)