Skip to main content

Chapter 4: Global Variables and Core Settings

Two files hold the values that apply to the whole system: vars.xml, which defines the global preprocessor variables, and switch.conf.xml, which sets the core runtime parameters. This chapter documents both.

Global Variables in vars.xml

vars.xml is included first by freeswitch.xml, so the preprocessor variables it defines are available to every file assembled afterward. Each is set with the set preprocessor instruction and referenced elsewhere as $${name}.

<X-PRE-PROCESS cmd="set" data="default_password=1234"/>
<X-PRE-PROCESS cmd="set" data="domain=$${local_ip_v4}"/>
<X-PRE-PROCESS cmd="set" data="sound_prefix=$${sounds_dir}/en/us/callie"/>
<X-PRE-PROCESS cmd="set" data="hold_music=local_stream://moh"/>

The set instruction cannot be commented out to disable it. Remove the line instead. This is noted directly in the file.

Dynamically Calculated Variables

FreeSWITCH computes a set of variables at startup and exposes them to the configuration as $${name}. You do not set these; you reference them. To see a computed value from the console, use eval, for example eval $${local_ip_v4}.

VariableValue
hostnameThe system hostname
local_ip_v4The primary IPv4 address
local_mask_v4The netmask for the primary IPv4 address
local_ip_v6The primary IPv6 address
switch_serialThe switch serial number
base_dirThe install base directory
conf_dirThe configuration root
sounds_dirThe sound files directory
recordings_dirThe recordings directory
log_dirThe log directory
db_dirThe database directory
script_dirThe scripts directory
certs_dirThe TLS certificate directory
storage_dirThe storage directory
temp_dirThe temporary directory
core_uuidThe unique id of this running instance
nat_public_addrThe discovered public NAT address
nat_private_addrThe discovered private NAT address
nat_typeThe detected NAT type

Commonly Edited Variables

These variables in vars.xml are the ones you are most likely to change.

VariablePurposeDefault
default_passwordShared password for the bundled test users1234
domainDefault SIP domain used for authentication and routing$${local_ip_v4}
domain_nameAlias of domain used in the directory$${domain}
sound_prefixPath prefix for prompt sound files$${sounds_dir}/en/us/callie
hold_musicSource for music on holdlocal_stream://moh
use_profileDefault outbound SIP profileexternal
global_codec_prefsCodecs offered on negotiationset in vars.xml
outbound_codec_prefsCodecs offered on outbound legsset in vars.xml
rtp_sdes_suitesSRTP crypto suites offered and acceptedset in vars.xml

Changing domain affects SIP authentication. Review the User Directory chapter before changing it. Codec variables are covered in the Codecs and Negotiation chapter.

Core Settings in switch.conf.xml

switch.conf.xml configures the core itself, in a <settings> block of <param name="..." value="..."/> elements. Most parameters are commented out in the default file and take an internal default until you enable them. The core also reads <cli-keybindings> and <default-ptimes> from this file.

<configuration name="switch.conf" description="Core Configuration">
<settings>
<param name="max-sessions" value="1000"/>
<param name="sessions-per-second" value="30"/>
<param name="loglevel" value="debug"/>
</settings>
</configuration>

Core Settings Reference

All parameters parsed by the core from the <settings> block of switch.conf.xml. The Default column reflects the internal code default when the parameter is absent from the configuration file; where the vanilla switch.conf.xml ships with the parameter explicitly set, that value is noted in parentheses.

Session and Call Control

ParameterPurposeAccepted ValuesDefault
max-sessionsMaximum simultaneous sessionsinteger1000
sessions-per-secondMaximum new sessions created per secondinteger30
multiple-registrationsAllow multiple registrations per account in the central registration tabletrue, falsefalse
max-audio-channelsMaximum audio channels per session; 0 means unlimitedinteger0 (unlimited)
enable-early-hangupHang up a channel as soon as the far end indicates hangup, before media teardown completestrue, falsefalse
min-idle-cpuMinimum idle CPU percentage before refusing new callsfloatunset (no limit)
tipping-pointNumber of active sessions at which FreeSWITCH begins shedding load; 0 disablesinteger0

Logging

ParameterPurposeAccepted ValuesDefault
loglevelGlobal log leveldebug, info, notice, warning, err, crit, alertdebug
debug-levelCore debug verbosity level0-100
colorize-consoleColorize console outputtrue, falsefalse (vanilla config ships true)
dialplan-timestampsInclude full timestamps in dialplan logstrue, falsefalse
verbose-channel-eventsInclude every channel variable on every channel eventtrue, falsefalse

Database

ParameterPurposeAccepted ValuesDefault
max-db-handlesMaximum simultaneous core database handles; must be between 5 and 5000integer50
db-handle-timeoutSeconds to wait for a database handle before failing; must be between 1 and 5000integer5 (vanilla config ships 10)
core-db-dsnDSN for an external core database; see below for formatDSN stringunset (uses SQLite)
core-db-nameAlternate path or name for the SQLite core database; an absolute path is used as-is; a bare name resolves to $${db_dir}/name.dbpath or name$${db_dir}/core.db
core-dbtypeDatabase type hint for SQL dialect; only MSSQL is recognized; any other value selects the default dialectMSSQLdefault dialect
auto-create-schemasCreate database schemas automatically on startuptrue, falsetrue
auto-clear-sqlClear SQL tables on startuptrue, falsetrue
odbc-skip-autocommit-flipSuppress the autocommit toggle FreeSWITCH normally performs on ODBC connectionstrue, falsefalse
core-non-sqlite-db-requiredAbort startup if no external database connection can be establishedtrue, falsefalse
core-db-pre-trans-executeSQL statement executed before each database transactionSQL stringunset
core-db-post-trans-executeSQL statement executed after each database transactionSQL stringunset
core-db-inner-pre-trans-executeSQL statement executed before each inner database transactionSQL stringunset
core-db-inner-post-trans-executeSQL statement executed after each inner database transactionSQL stringunset

Setting core-db-dsn moves the core database to PostgreSQL or MariaDB; this requires loading mod_pgsql or mod_mariadb. Example DSN formats:

pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password=''
postgresql://user:secret@localhost/freeswitch
mariadb://Server=localhost;Database=freeswitch;Uid=freeswitch;Pwd=pass;
dsn:username:password

RTP

ParameterPurposeAccepted ValuesDefault
rtp-start-portLowest UDP port allocated for RTPport number16384
rtp-end-portHighest UDP port allocated for RTPport number32768
rtp-port-usage-robustnessTest each port to confirm it is not in use before allocating it to RTPtrue, falsefalse
rtp-retain-crypto-keysStore SRTP encryption keys in channel variables and CDRs; enabling this allows anyone with CDR access to decrypt secure mediatrue, falsefalse
ice-resolve-candidateResolve ICE candidatestrue, falsefalse

DTMF

ParameterPurposeAccepted ValuesDefault
min-dtmf-durationMinimum DTMF event duration in samples; events shorter than this are padded; cannot be set below 400integer400
max-dtmf-durationMaximum DTMF event duration in samples; events longer than this are truncated; cannot exceed 192000integer192000
default-dtmf-durationDTMF duration for originated events or events received without a durationinteger2000

Timing

ParameterPurposeAccepted ValuesDefault
1ms-timerRun the core timer at 1 ms resolution instead of the default 20 mstruefalse
enable-monotonic-timingUse monotonic clock for timingtrue, falsefalse
enable-clock-nanosleepUse clock_nanosleep for timer wake-upstrue, falsefalse
enable-softtimer-timerfdUse Linux timerfd for the soft timer; accepted values are true, false, broadcast, or fd-per-timertrue, false, broadcast, fd-per-timerfalse
enable-cond-yieldEnable conditional yielding in the timertrue, falsefalse
enable-timer-matrixEnable the timer matrixtrue, falsefalse
timer-affinityCPU affinity for the timer thread; disabled pins to no CPU; an integer pins to that CPU indexdisabled or integerdisabled
cpu-idle-smoothing-depthNumber of CPU idle samples to average when computing idle percentageinteger0

System Execution

ParameterPurposeAccepted ValuesDefault
threaded-system-execRun system() calls in a dedicated thread; not supported on Windowstrue, falsetrue (non-Windows)
spawn-instead-of-systemUse posix_spawn instead of system() for external commands; not supported on Windowstrue, falsefalse
session-thread-poolUse a thread pool for session threads instead of allocating a thread per sessiontrue, falsetrue

Events

ParameterPurposeAccepted ValuesDefault
event-heartbeat-intervalInterval in seconds between HEARTBEAT eventsinteger20
events-use-dispatchRoute events through a dispatch thread pooltrue, falsetrue
initial-event-threadsNumber of event dispatch threads to launch at startup; implicitly enables events-use-dispatch; capped at half the CPU countintegerunset
api-expansionAllow API expansion in event headerstrue, falsetrue
event-channel-key-separatorSeparator character for event channel key hierarchystring.
event-channel-enable-hierarchy-deliverDeliver events to all parent nodes in the channel hierarchytrue, falsefalse
event-channel-hierarchy-deliver-onceDeliver a hierarchical event only once even if matched by multiple subscriberstrue, falsefalse
event-channel-log-undeliverable-jsonLog event channel messages that cannot be deliveredtrue, falsefalse

Identity

ParameterPurposeAccepted ValuesDefault
switchnameOverride the system hostname for database and CURL identity; useful in HA clusters where nodes share a config but must present different identitiesstringsystem hostname
uuid-versionUUID version used for channel IDs4, 74

Miscellaneous

ParameterPurposeAccepted ValuesDefault
mailer-appProgram used to send voicemail emailprogram namesendmail
mailer-app-argsArguments passed to mailer-appstring-t
dump-coresRemove core dump size limits so crashes produce a core file; requires HAVE_SETRLIMITyes, nono
enable-use-system-timeUse system wall clock time rather than FreeSWITCH internal timetrue, falsefalse
exclude-error-log-from-xml-cdrExclude the error log from XML CDR outputtrue, falsefalse
caller-profile-soft-variables-uses-prefixPrefix soft variables in caller profilestrue, falsefalse
caller-profile-soft-lookup-valuesLook up soft variable values in caller profilestrue, falsefalse

Console Key Bindings

switch.conf.xml maps function keys in fs_cli to commands through <cli-keybindings>. Each <key> maps a number, surfaced as a function key, to a command string.

<cli-keybindings>
<key name="1" value="help"/>
<key name="2" value="status"/>
<key name="5" value="sofia status"/>
<key name="6" value="reloadxml"/>
</cli-keybindings>
KeyDefault command
F1help
F2status
F3show channels
F4show calls
F5sofia status
F6reloadxml
F7console loglevel 0
F8console loglevel 7
F9sofia status profile internal
F10sofia profile internal siptrace on
F11sofia profile internal siptrace off
F12version

Logging Configuration

FreeSWITCH routes log output through one or more logger modules. Each logger registers itself with the core and receives log records independently. The core loglevel parameter in switch.conf.xml sets the global ceiling: the core discards records above that level before they reach any logger. Each logger then applies its own filter on top of that ceiling. A logger cannot surface levels that the core has already discarded.

Log Levels

FreeSWITCH defines 8 log levels, listed here from lowest numeric value to highest verbosity. The numeric values are used by the console loglevel command; the names are used in configuration files.

NumericNameMeaning
0consoleOutput directed specifically at the console channel
1alertImmediate action required
2critCritical conditions
3errError conditions
4warningWarning conditions
5noticeNormal but significant events
6infoInformational messages
7debugDebug-level messages

The core loglevel in switch.conf.xml accepts the name values (debug, info, notice, warning, err, crit, alert). Setting it to warning means only warning, err, crit, and alert records reach the loggers. The vanilla config ships with loglevel set to debug, which passes all records to the loggers; each logger then applies its own filter.

mod_console

mod_console writes log output to the FreeSWITCH console (the terminal or fs_cli session). It is configured in console.conf.xml.

Settings

ParameterPurposeAccepted ValuesDefault
colorizeEmit ANSI color codes to distinguish log levelstrue, falsefalse
loglevelMaximum level this logger accepts; records above this level are suppressedconsole, alert, crit, err, warning, notice, info, debugdebug
uuidPrefix each log line with the session UUIDtrue, falsefalse
jsonEmit log lines as JSON objects instead of plain texttrue, falsefalse

The vanilla config sets loglevel to the preprocessor variable $${console_loglevel}, which vars.xml defines as info. To pass all levels to the console, set loglevel to debug.

<configuration name="console.conf" description="Console Logger">
<settings>
<param name="colorize" value="true"/>
<param name="loglevel" value="info"/>
</settings>
<mappings>
<map name="all" value="console,debug,info,notice,warning,err,crit,alert"/>
</mappings>
</configuration>

Level Maps

The <mappings> block controls which levels appear for specific source files or functions. Each <map> element has a name attribute identifying the source file name, function name, or all, and a value attribute listing one or more comma-separated level names.

  • name="all" applies to every source location. When present, it overrides any other map entries.
  • A named entry applies only when the log record originates from that file or function. Named entries allow enabling verbose output for one module without affecting the rest.
<mappings>
<!-- Pass all levels globally -->
<map name="all" value="warning,err,crit,alert"/>
<!-- Also pass debug and info from a specific source file -->
<map name="mod_sofia.c" value="debug,info,warning,err,crit,alert"/>
</mappings>

The level values in a <map> entry are a mask, not a threshold. Listing warning,err,crit,alert passes exactly those four levels and nothing else. Use all as the value to pass every level.

The console loglevel API command adjusts the loglevel setting at runtime without reloading configuration. The console colorize, console uuid, and console json commands toggle the corresponding settings at runtime as well.

mod_logfile

mod_logfile writes log output to one or more files. It is configured in logfile.conf.xml. The file uses a profile-based structure: one global <settings> block holds the HUP behavior, and each <profile> inside <profiles> defines an independent log destination with its own path, rotation policy, and level filter.

Global Settings

ParameterPurposeAccepted ValuesDefault
rotate-on-hupWhen FreeSWITCH receives SIGHUP, rotate the log file instead of closing and reopening ittrue, falsefalse

Profile Settings

ParameterPurposeAccepted ValuesDefault
logfileAbsolute path to the log filepath string$${log_dir}/freeswitch.log
rolloverSize in bytes at which the log file is rotated; 0 disables size-based rotationinteger10485760 (about 10 MB; vanilla ships 1048576000)
maximum-rotateMaximum number of rotated log files to keep; when set, filenames use a numeric suffix (.1, .2, ...) instead of a date stamp; the oldest file is deleted when the limit is reached; 0 disables the capinteger0 (no cap; uses date-stamped filenames)
uuidPrefix each log line with the session UUIDtrue, falsetrue

The vanilla config ships with rollover set to 1048576000 (approximately 1 GB) and maximum-rotate set to 32, which produces up to 32 numbered rotation files (freeswitch.log.1 through freeswitch.log.32).

Rotation Behavior

Size-based rotation triggers automatically when the current log file reaches the rollover byte threshold. Signal-based rotation behavior depends on rotate-on-hup:

  • rotate-on-hup true: receiving SIGHUP rotates each profile's log file.
  • rotate-on-hup false: receiving SIGHUP closes and reopens each profile's log file without renaming it, which is suitable for external log rotation tools that rename the file themselves and then send SIGHUP.

When maximum-rotate is set to a nonzero value, rotation renames the current log file to logfile.1, shifts prior numbered files up by 1, and deletes the file that would exceed the maximum. When maximum-rotate is 0 (the default), rotation appends a date-time stamp and an index to the filename.

Profile Level Maps

Each profile has a <mappings> block that works identically to the one in console.conf.xml: <map> elements with name (file, function, or all) and value (comma-separated level names or all).

<configuration name="logfile.conf" description="File Logging">
<settings>
<param name="rotate-on-hup" value="true"/>
</settings>
<profiles>
<profile name="default">
<settings>
<param name="logfile" value="/var/log/freeswitch/freeswitch.log"/>
<param name="rollover" value="52428800"/>
<param name="maximum-rotate" value="10"/>
<param name="uuid" value="true"/>
</settings>
<mappings>
<map name="all" value="notice,warning,err,crit,alert"/>
</mappings>
</profile>
</profiles>
</configuration>

Multiple profiles may exist in one logfile.conf.xml. Each is loaded independently, so you can direct different level sets to different files.

mod_syslog

mod_syslog forwards log records to the system syslog daemon. It is configured in syslog.conf.xml and is not loaded by default.

Settings

ParameterPurposeAccepted ValuesDefault
identThe identity string passed to openlog(); appears as the program name in syslog entriesstringfreeswitch
facilityThe syslog facilityauth, cron, daemon, kern, local0-local7, lpr, mail, news, syslog, user, uucp (and authpriv, ftp where available)user
loglevelMaximum FreeSWITCH log level forwarded to syslog; records above this level are droppedconsole, alert, crit, err, warning, notice, info, debugwarning
uuidPrefix each syslog message with the session UUIDtrue, falsetrue

FreeSWITCH log levels map to syslog priorities as follows: debug to LOG_DEBUG, info to LOG_INFO, notice to LOG_NOTICE, warning to LOG_WARNING, err to LOG_ERR, crit to LOG_CRIT, alert to LOG_ALERT. The console level maps to LOG_NOTICE.

mod_syslog does not support per-source-file or per-function level maps. The loglevel parameter is a single global threshold for this logger.

The format parameter is parsed from the configuration file but has no effect in the current implementation; log lines are passed to syslog() as plain text regardless of its value.

<configuration name="syslog.conf" description="Syslog Logger">
<settings>
<param name="ident" value="freeswitch"/>
<param name="facility" value="local0"/>
<param name="loglevel" value="notice"/>
<param name="uuid" value="true"/>
</settings>
</configuration>

Enabling Logger Modules

Logger modules are loaded through modules.conf.xml in the autoload_configs directory, inside the <modules> block.

mod_console and mod_logfile are loaded by default in the vanilla configuration:

<load module="mod_console"/>
<load module="mod_logfile"/>

mod_syslog is present but commented out:

<!-- <load module="mod_syslog"/> -->

To enable mod_syslog, remove the comment delimiters and ensure syslog.conf.xml is present in the autoload_configs directory.

All three modules can be loaded simultaneously. Each independently receives log records from the core and applies its own filter, so a record that passes the global loglevel ceiling may be passed to the console, written to file, and forwarded to syslog at the same time if all three loggers are loaded and their filters include that level.