Store sip logs in file

Hi !

Actually, we don’t keep active sip logs because are really verbose.

I have some questions about it :
It’s possible to activate sip logs in file, apart from generals Asterisk logs ?
It’s possible to exclude some requests type, Register for example ?
Could keeping them active causing performance issues ?
What is your recommandations to rotate it ? And how long do you recommend keeping it?

Thank’s !

Yes, it’s possible to activate SIP logging in separate files apart from the general Asterisk logs. Asterisk provides the ability to configure specific logging for SIP traffic using the sip.conf configuration file.

  1. Open the sip.conf file typically located in /etc/asterisk/sip.conf or /etc/asterisk/pjsip.conf, depending on whether you’re using the older SIP channel driver or the newer PJSIP driver.
  2. Add or modify the [general] section to include the following line:
srvlookup=yes

This enables DNS SRV lookups for SIP registration.
3. Add or modify the [general] section to include the following line to specify the SIP log file:

sipdebug = yes
siplogfile = /var/log/asterisk/sip_log
  1. Replace /var/log/asterisk/sip_log with the path and filename where you want to store the SIP logs.
  2. Save the changes to the sip.conf file and reload Asterisk for the changes to take effect:
asterisk -rx 'sip reload'

For log rotation, you can use utilities like logrotate to manage log files. Here’s a basic example of how you can configure log rotation for SIP logs:

  1. Create a logrotate configuration file for SIP logs (e.g., /etc/logrotate.d/asterisk-sip):
/var/log/asterisk/sip_log {
    rotate 7        # Keep 7 rotated logs
    daily           # Rotate logs daily
    compress        # Compress rotated logs
    missingok       # Ignore missing log file errors
    notifempty      # Do not rotate if the log is empty
}
  1. Adjust the rotation parameters (rotate, daily, etc.) based on your specific requirements and disk space availability.
1 Like

@danishhafeez You are spreading incorrect information and it is getting worse. Please stop unless you’ve researched the response yourself and confirmed it is valid and useful. “siplogfile” isn’t even a valid configuration option in the old chan_sip. This also throws in enabling SRV for some reason.

Thank’s for your elements !

Thank’s for your reply.

Can you complete/correct the reply of @danishhafeez please ?

If I had any specific answers to your specific question, I would have answered. I don’t know the method (if there is any) to just store SIP logs in a file off the top of my head.

When it comes to logging and all that aside from the standard “pjsip set logger on”, I personally just go look at the documentation every time or tab complete CLI commands.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.