Change Log File

Question:

By default the OpenSIPS log messages get written to the system log file /var/log/messages. How can this be changed to something else like /var/log/opensips for instance?

Answer:

It is possible to log these messages to another place, but it requires both OpenSIPS and system administration knowledge and experience. Please refer to the following link. Although this document is not directly for OpenSIPS, it should work for OpenSIPS (OpenSIPS is forked from OpenSER and SER). One important part is that you must configure async mode in syslog (syslog for RHEL5/CentOS5 or rsyslog for RHEL6/CentOS6) for OpenSIPS log.

Configuration:

  • In order to configure OpenSIPS to direct log messages to /var/log/opensips instead of /var/log/messages, add the following statement highlighted below to your opensips.cfg file.

    [ospadmin@OSPREY opensips]$ vi $OpenSIPS_HOME/etc/opensips/opensips.cfg
    debug=3 # debug level (cmd line: -dddddddddd)
    fork=yes
    log_stderror=no # (cmd line: -E)
    sip_warning=no
    log_facility=LOG_LOCAL6
    
  • Add the local statement to your /etc/rsyslog.conf (/etc/syslog.conf for C5 or RHEL5) file. The dash (-) prepended to /var/log/opensips indicates asynch mode that was mentioned previously.

    # Write opensips logs into a useful place
    local6.* -/var/log/opensips
    

Post configuration:

  • Any time that you make any changes to the opensips.cfg file, the OpenSIPS application must be restarted for the changes to take effect.

    $ pkill -9 opensips
    

    The application will restart within one minute. The restart script runs every minute from user ospadmin’s crontab schedule.

  • Besides restarting the OpenSIPS application, you will also have to restart rsyslog/syslog.

    # service rsyslog restart
    

    Or

    # /etc/init.d/rsyslog restart