Skip to content

XLOG module

This module provides the possibility to print user formatted log or debug messages from OpenSIPS scripts, similar to printf function. A C-style printf specifier is replaced with a part of the SIP request or other variables from system. sec implemented specifiers shows what can be printed out.

In the xlog function, you use pseudo-variables, that are a part of OpenSIPS core and are used by other modules as well (e.g., avpops in the function avp_printf())

The most important changes from earlier versions of OpenSIPS are:

    • ’%’ has been replaced by ’$’
    • to print a header, use now $hdr(header_name[index]) instead of %{header_name[index]}
    • to print an AVP, use now $avp([si]:avp_id[index]) instead of %{[si]:avp_id[index]} or $avp([$avp_alias[index]) instead of %{[$avp_alias[index]}

The full list of available pseudo-variables in OpenSIPS is availabe at: http://opensips.org/dokuwiki/

The following modules must be loaded before this module:

  • No dependencies on other OpenSIPS modules.

The following libraries or applications must be installed before running OpenSIPS with this module loaded:

  • None.

Maximum size of the log message.

Default value is 4096.

Set buf_size parameter
...
modparam("xlog", "buf_size", 8192)
...

When set to 1, forces color printing even if log_stderror=0.

Default value is 0.

Set force_color parameter
...
modparam("xlog", "force_color", 0)
...

Print a formated message using LOG function.

Meaning of the parameters are as follows:

  • level - The level that will be used in LOG function. It can be:

    • L_ALERT - log level -3
    • L_CRIT - log level -2
    • L_ERR - log level -1
    • L_WARN - log level 1
    • L_NOTICE - log level 2
    • L_INFO - log level 3
    • L_DBG - log level 4
    • $pv - any valid pseudo-variable, that has an integer value. See above options for valid log levels. If it is not a pseudo-variable, then what really matters is the third letter of the value. If the log level is higher than the “debug” global parameter, the message is not printed to syslog. If this parameter is missing, the implicit log level is ‘L_ERR’.
  • format - The formatted string to be printed.

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, ONREPLY_ROUTE, BRANCH_ROUTE.

xlog usage
...
xlog("L_ERR", "time [$Tf] method ($rm) r-uri ($ru) 2nd via ($hdr(via[1]))\n");
...
xlog("time [$Tf] method ($rm) r-uri ($ru) 2nd via ($hdr(via[1]))\n");
...
$var(loglevel) = 2;
xlog("$var(loglevel)", "time [$Tf] method ($rm) r-uri ($ru)\n");
...

Print a formatted message using DBG function.

Meaning of the parameters is as follows:

  • format - The formatted string to be printed.

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, ONREPLY_ROUTE, BRANCH_ROUTE.

xdbg usage
...
xdbg("time $Cbx[$Tf]$Cxx method ($rm) r-uri ($ru)\n");
...

Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)

#NameDevScoreCommitsLines++Lines—
1.Daniel-Constantin Mierla (@miconda)52185091727
2.Elena-Ramona Modroiu26101378233
3.Bogdan-Andrei Iancu (@bogdan-iancu)1510147142
4.Elena-Ramona Modroiu8514642
5.Jan Janak (@janakj)724004
6.Stefan Darius (@dariusstefan)6319020
7.Jiri Kuthan (@jiriatipteldotorg)426127
8.Henning Westerholt (@henningw)421010
9.Andrei Pelinescu-Onciul4285
10.Anca Vamanu4233

All remaining contributors: Andreas Heise, Razvan Crainea (@razvancrainea), Konstantin Bokarius, Edson Gellert Schubert.

(1) DevScore = author_commits + author_lines_added / (project_lines_added / project_commits) + author_lines_deleted / (project_lines_deleted / project_commits)

(2) including any documentation-related commits, excluding merge commits

(3) ignoring whitespace edits, renamed files and auto-generated files

#NameCommit Activity
1.Stefan Darius (@dariusstefan)Jun 2026 - Jul 2026
2.Razvan Crainea (@razvancrainea)Jun 2026 - Jun 2026
3.Bogdan-Andrei Iancu (@bogdan-iancu)Aug 2005 - Jul 2008
4.Henning Westerholt (@henningw)Dec 2007 - Jun 2008
5.Daniel-Constantin Mierla (@miconda)Jun 2005 - Mar 2008
6.Elena-Ramona ModroiuSep 2005 - Mar 2008
7.Konstantin BokariusMar 2008 - Mar 2008
8.Edson Gellert SchubertFeb 2008 - Feb 2008
9.Anca VamanuOct 2007 - Oct 2007
10.Andreas HeiseOct 2007 - Oct 2007

All remaining contributors: Elena-Ramona Modroiu, Jiri Kuthan (@jiriatipteldotorg), Jan Janak (@janakj), Andrei Pelinescu-Onciul.

(1) including any documentation-related commits, excluding merge commits

Last edited by: Razvan Crainea (@razvancrainea), Bogdan-Andrei Iancu (@bogdan-iancu), Henning Westerholt (@henningw), Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert, Elena-Ramona Modroiu, Elena-Ramona Modroiu, Jan Janak (@janakj).

All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0