# Logging

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)

• DEBUG
• INFO
• WARNING
• ERROR
• FATAL

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.

# Setting the Log Level

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.

## For a Single Node

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.

## For all Nodes

export ROSCONSOLE_CONFIG_FILE="\$HOME/.rosconsole.config"

Then run:

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.

## Programatically

Yes, you can make a node set its log level by itself! Check out this example.