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

How to set verbosity/logger levels programmatically?

asked 2012-09-07 17:06:35 -0500

tor gravatar image

updated 2012-09-07 17:07:06 -0500

Hi All,

Is there a way to set verbosity/logger levels programmatically (up to node levels if possible)? How?

I have looked at here and here. It seems that I should somehow use log4cxx::Logger, cmiiw, but still do not know exactly how? Please help.

Thanks a lot. PS: Hopefully, for both roscpp and rospy (+roslisp)

edit retag flag offensive close merge delete


Rufus gravatar image Rufus  ( 2020-05-17 23:39:20 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2015-11-20 13:32:16 -0500

hvpandya gravatar image

Or simply add

 if( ros::console::set_logger_level(ROSCONSOLE_DEFAULT_NAME, ros::console::levels::Debug) )

in your nodes constructor. Replace Debug with your required logger level.

Don't forget to

#include <ros/console.h>
edit flag offensive delete link more

answered 2015-11-20 09:50:18 -0500

Avio gravatar image

updated 2015-11-20 09:53:48 -0500

For anybody stumbling upon this page, if you just want to set verbosity of packages as soon as they are launched by launchfiles, the easiest way is:

  1. to export ROSCONSOLE_CONFIG_FILE="/path/to/my/config/rosconsole.config"
  2. edit, for example with vi /path/to/my/config/rosconsole.config adding these lines:




3. launch your launchfile in the same shell.

The package name must be the one who corresponds to <node pkg="my_package_name" ...> line in the launchfile.

edit flag offensive delete link more

answered 2012-09-08 10:28:56 -0500

updated 2017-02-22 17:42:28 -0500

I do this quite often when writing new nodes in C++. Usually what I do is place the following little snippet right after my call to ros::init

log4cxx::LoggerPtr my_logger =

This will set the node's log level to Debug. Then I comment it out after the node is sufficiently developed. I have never really looked into doing this in rospy or roslisp, but would also be interested in figuring out how.


I just realized that this is quite easy to do with rospy as well. As documented here, you can simply pass the log_level argument to a call to rospy.init_node() e.g.

rospy.init_node('my_node', log_level=rospy.DEBUG)
edit flag offensive delete link more


For completeness: in roslisp you have the method set-debug-level to set the level of a specific logger.

Lorenz gravatar image Lorenz  ( 2012-09-10 05:43:05 -0500 )edit

You should not use `g_level_lookup` to map the ROS debug level to the log4cxx log level. Instead use the log4cxx level directly. Besides the package must specify a dependency on log4cxx in its package manifest and the cpp file must include the necessary log4cxx header(s).

Dirk Thomas gravatar image Dirk Thomas  ( 2014-01-14 13:45:51 -0500 )edit

Question Tools



Asked: 2012-09-07 17:06:35 -0500

Seen: 6,361 times

Last updated: Feb 22 '17