We use the ROS logging API for having programs produce output. See The official documentation for more details.
There are 5 logging levels (ordered in increasing severity)
Here are some general guidelines for when to use each level. If you use the FATAL message, your node should use a call to exit(nonzero value) very soon (if not immediately) after publishing the message.
By default, only severity >= INFO is logged and displayed. There are several ways of changing the log level of a particular node, or all nodes.
Use the rosconsole command from the command line. Note this can only be applied to a currently running node, so it isn't very useful if you have debug messages in the startup of your node that you want to see.
Modify your .bashrc file and add the following line:
echo "log4j.logger.ros=DEBUG" > ~/.rosconsole.config
You can replace DEBUG with another log level.
This is useful if you want to see debugging messages for all the nodes.
Yes, you can make a node set its log level by itself! Check out this example.