Note: These instructions are for Kamailio 4.0.x and Ubuntu
Recently, I installed Kamailio on a small VPS I have. After getting tired of constantly grepping syslog, I finally decided to setup Kamailio so that all of it’s debug output and messages would go to a separate file. In my case, /var/log/kamailio.
First, open up your Kamailio configuration file (/etc/kamailio/kamailio.cfg in my case) with your editor of choice and add the following line some where near the top:
Next, search the file for the “log_stderror” lines and change them both to ‘no’ like so:
#!ifdef WITH_DEBUG debug=4 log_stderror=no #!else debug=4 log_stderror=no #!endif
Setting log_stderr to no tells Kamailio to write messages to syslog instead of stderr. Not to far below that you should see another line called “log_facility”. Change it to “LOG_LOCAL0”.
Save and exit the file. We need to modify the rsyslog config file so it knows that anything from local0 should go into our custom log file. On Ubuntu 14.04, you can open up “/etc/rsyslog.d/50-default.conf”.
At the bottom of the file add this:
Save and exit the file. Now create the kamailio log file and modify its permissions.
# touch /var/log/kamailio # chown syslog /var/log/kamailio # chgrp adm /var/log/kamailio
Finally, restart rsyslog and Kamailio.
# service rsyslog restart # kamctl restart
You can verify everything is working properly by checking our log file. Using, “ls -l /var/log/kamailio”, you should see something similar to what’s below:
-rw-r--r-- 1 syslog adm 543464 Feb 11 21:50 /var/log/kamailio
Question or comment ? Let me know on twitter or email.