– Kamailio SIP Server –

Basic OpenSER Logging

This is a way to setup syslog logging for OpenSER. This setup was based on Slackware 10.2, so your configuration may need to be modified for your distribution.

Configuration

OpenSER Configuration

First, set these configuration options in your openser.cfg:

debug=3  # debug level, 1 is low and 7 is high (lots of output)
log_facility=LOG_LOCAL7

loadmodule "/usr/local/lib/openser/modules/xlog.so"

Syslog Configuration

Next, modify your syslog.conf (should be in /etc/syslog.conf), and add this line:

# OpenSER messages, make sure this spacing is done with tabs, spaces may cause errors
local7.*;                                            -/var/log/openser

Create the log file:

touch /var/log/openser

Now, in OpenSER, to do some custom logging within your route (it will still catch all regular output from OpenSER, of course), I like to use xlog. Regular log will work, too.

Extra Logging in 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/openser

Each distribution may be different, but in Slackware 10.2, I created a the file /etc/logrotate.d/openser

I filled it with these parameters:

/var/log/openser {
    sharedscripts
    postrotate
	/bin/kill -HUP `cat /var/run/syslogd.pid 2>/dev/null` 2>/dev/null || true
    endscript
}

Finally, restart OpenSER and enjoy!

Questions and corrections, please email to mikebwilliams@gmail.com, or feel free to correct this Wiki yourself.