Menu Close

Kamailio logging how to – debian lenny

Kamailio supports many kinds of debugging and message logging. I will try describe some which I'm using during my Kamailio testing. My OS is debian.

Rsyslog logging

Open file for rsyslog at /etc/rsyslog.conf

vim /etc/rsyslog.conf

and add rule for message sended from Kamailio, in my case identified by local0, which will be saved into a special file for kamailio logging, here /var/log/kamailio.log

#### RULES ####

local0.*                        -/var/log/kamailio.log

then restart your rsyslog daemon (service)

/etc/init.d/rsyslog restart
Stopping enhanced syslogd: rsyslogd.
Starting enhanced syslogd: rsyslogd.

Then open your kamailio.cfg file and add line


and restart the kamailio service.


Using kamailio

Kamailio allows to set up its configuration to support different level of logging, look at the tutorial

Logging in Kamailio (OpenSER) can be configured using the following options. Core options are located at the beginning of the configuration file, before loading modules and any routing block.

  • debug – set log level, this is number between 0 and 9. Default is 0. The higher the number the more information will be written to the log. The default level (if no debug is present in the config file and no -d parameter on the command line) is 2 (L_NOTICE).
  • log_stderror – if set to “yes”, the server will print its debugging information to standard error output. If set to “no”, syslog will be used. Default is “no” (printing to syslog).
  • memlog – debugging level for final memory statistics report. Default is “L_DBG” – memory statistics are dumped only if “debug” option has higher value.
  • log_facility – is used to specify what type of program is logging the message. Valid values to use with OpenSER are “LOG_LOCAL0” through “LOG_LOCAL7”. See the manual page of syslog for more information.

Setting up debug level

Kamilio allow to setup the debug level with debug command.

Set the debug level. Higher values make kamailio to print more debug messages. Log messages are usually sent to syslog, except logging to stderr was activated (see log_stderror parameter).

The following log levels are defined:

L_BUG -4
L_CRIT2 -3
L_ERR -1
L_DBG 3 

Tunning number of messages

If there is a big volumes of messages, and most of theme are about memory (memdbg for debugging and memlog for statistics). We may decrease the number of messages with turning off memory debugging and statistics. To do that, the debug level have to be lower as memory statistics level and memory debug level (memlog, memdbg).

From the core cookbook memlog about memdbg.


This will not log mem debugs and statistics

debug=3    # 
memdbg=4   # memory debugging is not active as the debug level is lower than memdbg
memlog=4   # dumping of memory statistics is not active as the debug level is lower than memlog

This will not log mem debugs and statistics

debug=3    # 
memdbg=2   # memory debugging is active as the debug level is higher or equal memdbg
memlog=2   # dumping of memory statistics is active as the debug level is higher or equal memlog

Running kamailio in frontend

The kamailio service have to be stopped, and we start the kamilio with following command (look kamailio -h):

kamailio -dd -D 2




tail -f /var/log/kamailio.log

to see in a real time how messages are added to the kamailio log file

www links

Links with guides:



Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.