– Kamailio SIP Server –

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
old-content:basic_openser_syslog_tutorial [2011/09/02 10:46]
92.112.43.124
old-content:basic_openser_syslog_tutorial [2012/03/22 13:41] (current)
80.250.1.245 removed spam
Line 1: Line 1:
 +====== 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:​
 +
 +<​code>​
 +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"​
 +</​code>​
 +
 +==== Syslog Configuration ====
 +
 +Next, modify your syslog.conf (should be in /​etc/​syslog.conf),​ and add this line:
 +
 +<​code>​
 +# OpenSER messages, make sure this spacing is done with tabs, spaces may cause errors
 +local7.*; ​                                           -/​var/​log/​openser
 +</​code>​
 +
 +Create the log file:
 +
 +<​code>​touch /​var/​log/​openser</​code>​
 +
 +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 ====
 +
 +<​code>​
 +xlog("​L_WARN",​ "Some message at level WARNING"​);​
 +</​code>​
 +
 +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. 
 +
 +<​code>​
 +# /​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:
 +</​code>​
 +
 +==== /​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:
 +
 +<​code>​
 +/​var/​log/​openser {
 +    sharedscripts
 +    postrotate
 + /bin/kill -HUP `cat /​var/​run/​syslogd.pid 2>/​dev/​null` 2>/​dev/​null || true
 +    endscript
 +}
 +</​code>​
 +
 +Finally, restart OpenSER and enjoy!
 +
 +Questions and corrections,​ please email to mikebwilliams@gmail.com,​ or feel free to correct this Wiki yourself.