New PJSIP Logging Functionality

When PJSIP support was written for Asterisk we naturally needed the ability to display the SIP messages being sent and received. This took the form of the res_pjsip_logger module which hooks into the message sending and receiving path and logs the messages. The functionality was written to be familiar to users of chan_sip by allowing it to be toggled on and off and allowing a specific IP address or hostname to be specified. This has worked for some time but there is always room for improvement. As of Asterisk 13.34.0, 16.11.0, and 17.5.0 some new functionality is available alongside this!

Multiple IPs and Subnet Support

The “pjsip set logger host” CLI command now supports specifying a subnet mask, for example:

pjsip set logger host 172.16.1.0/255.255.255.0

As well you can now place “add” at the end to have it be an additional host or subnet to log for:

pjsip set logger host 172.16.1.0/255.255.255.0 add

Console Disabling Support

In some cases you may not want PJSIP logging to go to the console. There is now a CLI command to toggle this on and off:

pjsip set logger verbose off

PCAP Output Support

Finally a really handy option is the ability to output messages in a pcap file, so you can later filter and view in such tools as Wireshark:

pjsip set logger pcap /tmp/packets.cap

Packets are placed into the pcap as UDP packets in all cases and they are unencrypted. This even applies if you are using, for example, SIP over Websockets with TLS.

The Future

Adding these changes also provided the foundation for potential future improvements. These could be the ability to have multiple independent logging sessions going on or the ability to also include RTP packets in the pcap file as well. Stay tuned in case these or other things are added!

5 Responses

  1. Is the command “pjsip set logger host 172.16.1.0/255.255.255.0” rather than “pjsip set logger on 172.16.1.0/255.255.255.0” ?

  2. Hi Asterik Team,

    I am Burhan, working in Information Security Domain. I would like to know how the logging is maintained in Asterik Call Manager software. One of my clients is uisng Asterik but they are not aware of its logging mechanism and do not know from where they can assess the logs.

  3. Hi, I use Ubuntu 20 and Asterisk 18.10. When I use ‘pjsip set logger pcap /tmp/file_name.pcap’ and make calls, the file does not increase its size. After completing all calls, I turn off the logger using ‘pjsip set logger off’ and the file size is set to 24 bytes. Is this a bug?

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

About the Author

What can we help you find?