Sunday, November 3, 2013

Changing Kannel Log Level & Log Rotation

If Kannel is configured so that the bearerbox, wapbox and/or smsbox log to file each of these log files will continue to grow unless administered in some way.One way of  reducing logs is by change log level . kannel allow to have 5 log-level ( 0 - debug, 1 - info, 2 - warning, 3 - error, 4 - panic).We can change log level  by editing log-level component in configuration file and also done by admin HTTP command  without restaring bearerbox.

              http://localhost:13000/log-level?password=bar&level=2

Another way of administering log files is to 'rotate' the logs on a regular basis using a tool such as logrotate. A sample logrotate script is shown below.

Setup Logrotate

Step 1 : If logrotate is not already on your VPS, install it now.
             sudo apt-get install logrotate
Step 2 : Add following script in  file /etc/logrotate.d

        /var/log/kannel/*.log {
              daily
              missingok
              rotate 365
              compress
              delaycompress
              notifempty
              create 640 kannel adm
              sharedscripts
              postrotate
              killall -HUP bearerbox smsbox wapbox || true > /dev/null 2> /dev/null
              endscript
        }

In this example the Kannel log files found in /var/log/kannel are rotated and compressed daily over 365 days.To verify if a particular log is rotating or not and to check the last date and time of its rotation, check the  /var/lib/logrotate/status file.

             cat /var/lib/logrotate/status

No comments:

Post a Comment