AI and VoIP Blog

VOIP | AI | Cloud | Kamailio | Open Source


How to enable per module log facility on Kamailio


Kamailio is an open-source SIP server used for voice and video communication services. One of the key features of Kamailio is the ability to enable logging for individual modules, allowing developers to debug specific parts of the system. Generally the Kamailio logs are available in syslog file under”/var/log” directory. In this blog, we will look at how to enable per-module logging in Kamailio.

To enable per-module logging in Kamailio, you need to follow these steps:
Add the following line just after the first line in kamailio.cfg to enable debugger module.

!define WITH_DEBUG

Next, add the following debugger module parameters to enable per module logging.

modparam("debugger", "mod_hash_size", 4)
modparam("debugger", "mod_level_mode", 1)

Now, add the module and the debug level parameters to enable the logging for:

modparam("debugger", "mod_level", "core=3")
modparam("debugger", "mod_level", "tm=3")

Optional

The debugger module allows to save module specific logs to separate log files called facility mode. To enable this option you need to add the following parameters:

modparam("debugger", "mod_facility_mode", 1)
modparam("debugger", "mod_facility", "core=LOG_LOCAL0")
modparam("debugger", "mod_facility", "debugger=LOG_LOCAL1")

Now what is LOG_LOCAL* and how do we configure it?. Log locals are a way for applications to send logs to custom files. This can be done by assigning a file name to log local*. On ubuntu, which uses rsyslog you can add the following lines to “/etc/rsyslog.d/50-default.conf” file:

# Separate log files for local use
local0.*                        /var/log/local0
local1.*                        /var/log/local1

Then restart rsyslog service to apply your changes:

sudo systemctl restart rsyslog
sudo systemctl status rsyslog

The status of the service after restart should be active (running).

Conclusion

It’s worth noting that different modules have different logging levels available. You can find the available logging levels for each module in the Kamailio documentation, which can be found at https://kamailio.org/docs/modules/5.6.x/modules/debugger.html

In conclusion, enabling per-module logging in Kamailio is a simple process that can greatly help with debugging and troubleshooting. By enabling logging for individual modules, developers can pinpoint specific parts of the system that may be causing issues and quickly resolve them.

Join 753 other subscribers

Leave a comment

Akash Gupta
Senior VoIP Engineer and AI Enthusiast



Discover more from AI and VoIP Blog

Subscribe to get the latest posts sent to your email.



Leave a comment