I made a kamailio server which half works through the router and doesn't work locally (yes, I know, it's weird) and the main problem is I don't even know what is really happening and what the problem are as I can't see any log (I can see the startup messages so I know I'm looking in the right file).

First problem: by default kamailio log its stuff into /var/log/syslog, but it's a PITA and I'd like to change that so it logs into a dedicated file, something like /tmp/kamailio.log. I already searched but didn't found anyone who did that, it's just insane there's not a simple log_file="" in the config.

Second problem: besides the startup messages it logs nothing else. I added the WITH_DEBUG define in the config, and even added my own xlog() calls but not a single message is logged so I can't debug anything.

I'm so fed up with how complicated it is to make even a very simple VOIP server to work.

2

There are 2 best solutions below

0
On BEST ANSWER

I ditched kamailio and ended up using freepbx with asterisk. I'll never use kamailio ever again, too much hassle and too much time wasted.

2
On

By default, Kamailio writes the log messages to syslog, which is the standard practice for daemon applications on Unix/Linux systems. But it also has a mode to print the log messages to the terminal (standard output/error), a matter of the value for log_stderror global parameter or -E command line parameters.

If log_stderror=no global parameter and -E is not provided, then it writes to syslog daemon. It depends of the OS and its version what syslog application runs, it can be syslogd, syslog-ng, rsyslogd or systemd-journald.

If the syslog application is configured to write to file, you should see Kamailio log messages inside /var/log/syslog (usually on Debian/Ubuntu) or inside /var/log/messages (usually on Fedora/RedHat/openSuse).

By setting the log_facility in kamailio.cfg and then update the configuration of syslog application to filter on facility value, the logs printed by Kamailio can be diverted in a dedicated file such as /var/log/kamailio.log.

For example, when syslogd application is used and kamailio.cfg has log_facility==LOG_LOCAL0, then syslog.conf (usually inside /etc/) needs:

local0.*            -/var/log/kamailio.log

Some more snippets of configuration for specific syslog applications can be found on Kamailio wiki documentation:

Note that OSes running systemd may keep log messages only in memory and then they can be seen with journalctl, like journalctl -u kamailio.service. The OS can also be configured to write to a file by running one of the classic syslog application.

Shortly, by reading the SIP standardisation specifications from IETF (RFC3261 and so many others related to SIP), one could figure out it is not something simple at all. Telephony/Real Time Communication was never something easy to implement and operate. Covering all (or most of) the cases from the specifications and also adapting for world wide infrastructure challenges come with a certain degree of complexity.