Debugging

Several methods of debugging are available in Asterisk. Once you’ve connected to the console, you can enable different levels of verbosity and debugging output, as well as protocol packet tracing. We’ll take a look at the various options in this section.

Connecting to the Console

To connect to the Asterisk console, you can either start the server in the console directly (in which case you will not be able to exit out of the console without killing the Asterisk process), or start Asterisk as a daemon and then connect to a remote console.

To start the Asterisk process directly in the console, use the console flag:

# /usr/sbin/asterisk -c         

To connect to a remote Asterisk console, start the daemon first and then connect with the -r flag:

# /usr/sbin/asterisk
# /usr/sbin/asterisk -r         

If you are having a problem with a specific module not loading, or a module causing Asterisk to not load, start the Asterisk process with the -c flag to monitor the status of modules loading. For example, if you attempt to load the OSS channel driver (which allows the use of the CONSOLE channel), and Asterisk is unable to open /dev/dsp, you will receive the following error on startup:

WARNING[32174]: chan_oss.c:470 soundcard_init: Unable to open /dev/dsp: 
No such file or directory
  == No sound card detected -- console channel will be unavailable
  == Turn off OSS support by adding 'noload=chan_oss.so' in /etc/
     asterisk/modules.conf

Enabling Verbosity and Debugging

Asterisk can output debugging information in the form of WARNING, NOTICE, and ERROR messages. These messages will give you information about your system, such as registrations, status, and progression of calls, and various other useful bits of information. Note that WARNING and NOTICE messages are not errors; however, ERROR messages should be investigated. To enable various levels of verbosity, use set verbose followed by a numerical value. Useful values range from 3 to 10. For example, to set the highest level of verbosity, use:

# set verbose 10         

You can also enable core debugging messages with set debug followed by a numerical value. To enable DEBUG output on the console, you may need to enable it in the logger.conf file by adding debug to the console => statement, as follows:

console => warning,notice,error,event,debug         

Useful values for set debug range from 3 to 10. For example:

# set debug 10