Table of Contents
Basic Kamailio (OpenSER) Logging
This is a way to setup syslog logging for Kamailio (OpenSER). This setup was based on Slackware 10.2, so your configuration may need to be modified for your distribution.
Configuration
Kamailio (OpenSER) Configuration
First, set these configuration options in your kamailio.cfg:
debug=3 # debug level, 1 is low and 4 is high (lots of output) log_facility=LOG_LOCAL7 loadmodule "/usr/local/lib/kamailio/modules/xlog.so"
Syslog Configuration
Next, modify your syslog.conf (should be in /etc/syslog.conf), and add this line:
# Kamailio (OpenSER) messages, make sure this spacing is done with tabs, spaces may cause errors local7.* -/var/log/kamailio
Remarks:
- the '-' before the name of the file means asynchronous writing, it is important to have it not to add performance penalty
- if you don't want messages from Kamailio to /var/log/messages anymore, be sure you add local7.none to the line related to that file
Create the log file:
touch /var/log/kamailio
Now, in Kamailio (OpenSER), to do some custom logging within your route (it will still catch all regular output from Kamailio, of course), I like to use xlog. Regular log will work, too.
Extra Logging in Kamailio (OpenSER)
xlog("L_WARN", "Some message at level WARNING");
The first argument sets the level of the logging, and the next is the message.
Log Rotation
logrotate.conf
Within /etc/logrotate.conf, you can configure general paramters for your log rotation. My Slackware setup by default looks like this.
# /etc/logrotate.conf # # logrotate is designed to ease administration of systems that generate large # numbers of log files. It allows automatic rotation, compression, removal, and # mailing of log files. Each log file may be handled daily, weekly, monthly, or # when it grows too large. # # logrotate is normally run daily from root's crontab. # # For more details, see "man logrotate". # rotate log files weekly: weekly # keep 4 weeks worth of backlogs: rotate 4 # create new (empty) log files after rotating old ones: create # uncomment this if you want your log files compressed: #compress # some packages install log rotation information in this directory: include /etc/logrotate.d # Rotate /var/log/wtmp: /var/log/wtmp { monthly create 0664 root utmp rotate 1 } # Note that /var/log/lastlog is not rotated. This is intentional, and it should # not be. The lastlog file is a database, and is also a sparse file that takes # up much less space on the drive than it appears. # system-specific logs may be also be configured below:
/etc/logrotate.d/kamailio
Each distribution may be different, but in Slackware 10.2, I created a the file /etc/logrotate.d/kamailio
I filled it with these parameters:
/var/log/kamailio { sharedscripts postrotate /bin/kill -HUP `cat /var/run/syslogd.pid 2>/dev/null` 2>/dev/null || true endscript }
Finally, restart Kamailio (OpenSER) & syslog and enjoy!
Questions and corrections, please email to mikebwilliams@gmail.com, or feel free to correct this Wiki yourself.