ROS Logging (roscpp and rospy) functionality allows for setting the verbosity of programs at run time through the rosconsole interface. The logging level specifies how verbose a program should be. The user can specify the verbosity at run-time. This is particularly helpful when you want debug by printing lots of diagnostic information and then return to normal (info level) logging when the issue is resolved.
Consider an example case were we are having trouble with the map_server node. We wish to turn up the verbosity by specifying that the DEBUG messages should be printed to the screen. There are a few ways to accomplish this, some of which are presented below.
Create a rosconsole Config File
You will need a configuration file to specify that we want to logging level of the map_server package to be DEBUG. The example below is supplied in the mrc_examples ROS package and as config/custom_rosconsole.conf.
This config file explicitly sets the logging level to DEBUG for the map_server package.
Method 1: Using the Custom Config in a Launch File
We can specify the use of this custom configuration file within a launch file. We also direct the map_server node output to the screen as demonstrated in the launch/map_server_debug.launch example.
You can run this example by cloning the mrc_examples ROS package (catkin_make, source ~/catkin_ws/devel/setup.bash, etc.) and...
which should generate output similar to...
where we can see that the DEBUG message is being printed to the screen.
Method 2: Using Environment Variable
An alternative is to set an environment variable to point to our config file...
and then run the map server node...
which should have the same result. For this method we have to be a bit more explicit by providing the full path to the configuration and map files.