Skip to main content

mod_logfile

About

The FreeSWITCH log file is, as its name implies, a detailed log of what FreeSWITCH has been doing. By default, all log messages get stored in the log file. This behavior can be customized.

Click here to expand Table of Contents

Log File Information

The current log file is named freeswitch.log. Rotated log files are named freeswitch.log.YYYY-MM-DD-hh-mm-ss.s.

Location

The default log file location is in the log subdirectory of the freeswitch install directory. On a typical Linux install this would be:

/usr/local/freeswitch/log

This location can be changed by editing the logfile.conf.xml file. Locate this line and modify accordingly:

 <!--<param name="logfile" value="/var/log/freeswitch.log"/>--> 

Contents

The log file will contain log lines in this general format:

YYYY-MM-DD hh:mm:ss [LEVEL] source_file_name:line_number function_name() <log data>

Sample Log Lines

A sample log file looks like this:

2009-01-19 11:46:40 [DEBUG] mod_dialplan_xml.c:117 parse_exten() Regex: [tone_stream] destination_number(9664) =~ /^9198$/
2009-01-19 11:46:40 [DEBUG] mod_dialplan_xml.c:119 parse_exten() Regex mismatch
2009-01-19 11:46:40 [DEBUG] mod_dialplan_xml.c:117 parse_exten() Regex: [hold_music] destination_number(9664) =~ /^9664$/
2009-01-19 11:46:40 [DEBUG] mod_dialplan_xml.c:117 parse_exten() Regex: [hold_music] ${sip_has_crypto}() =~ /^(AES_CM_128_HMAC_SHA1_32|AES_CM_128_HMAC_SHA1_80)$/
2009-01-19 11:46:40 [DEBUG] mod_dialplan_xml.c:119 parse_exten() Regex mismatch
2009-01-19 11:46:40 [DEBUG] switch_core_state_machine.c:100 switch_core_standard_on_routing() (sofia/internal/sip:1000@10.15.0.90:15324;rinstance=d891f9e6bafafb70) State Change CS_ROUTING -> CS_EXECUTE
2009-01-19 11:46:40 [DEBUG] switch_core_session.c:810 switch_core_session_signal_state_change() Send signal sofia/internal/sip:1000@10.15.0.90:15324;rinstance=d891f9e6bafafb70 [BREAK]
2009-01-19 11:46:40 [DEBUG] switch_core_state_machine.c:447 switch_core_session_run() (sofia/internal/sip:1000@10.15.0.90:15324;rinstance=d891f9e6bafafb70) State ROUTING going to sleep
2009-01-19 11:46:40 [DEBUG] switch_core_state_machine.c:379 switch_core_session_run() (sofia/internal/sip:1000@10.15.0.90:15324;rinstance=d891f9e6bafafb70) Running State Change CS_EXECUTE
2009-01-19 11:46:40 [DEBUG] switch_core_state_machine.c:454 switch_core_session_run() (sofia/internal/sip:1000@10.15.0.90:15324;rinstance=d891f9e6bafafb70) State EXECUTE
2009-01-19 11:46:40 [DEBUG] mod_sofia.c:173 sofia_on_execute() sofia/internal/sip:1000@10.15.0.90:15324;rinstance=d891f9e6bafafb70 SOFIA EXECUTE
2009-01-19 11:46:40 [DEBUG] switch_core_state_machine.c:137 switch_core_standard_on_execute() sofia/internal/sip:1000@10.15.0.90:15324;rinstance=d891f9e6bafafb70 Standard EXECUTE
2009-01-19 11:46:40 [DEBUG] switch_core_state_machine.c:152 switch_core_standard_on_execute() sofia/internal/sip:1000@10.15.0.90:15324;rinstance=d891f9e6bafafb70 Execute set(open=true)
2009-01-19 11:46:40 [DEBUG] mod_dptools.c:699 set_function() sofia/internal/sip:1000@10.15.0.90:15324;rinstance=d891f9e6bafafb70 SET [open]=[true]
2009-01-19 11:46:40 [DEBUG] switch_core_state_machine.c:152 switch_core_standard_on_execute() sofia/internal/sip:1000@10.15.0.90:15324;rinstance=d891f9e6bafafb70 Execute set(use_profile=${cond(${acl(${network_addr} rfc1918)} == true ? nat : default)})
2009-01-19 11:46:40 [DEBUG] switch_core_session.c:1257 switch_core_session_execute_application() sofia/internal/sip:1000@10.15.0.90:15324;rinstance=d891f9e6bafafb70 Expanded String set(use_profile=nat)
2009-01-19 11:46:40 [DEBUG] mod_dptools.c:699 set_function() sofia/internal/sip:1000@10.15.0.90:15324;rinstance=d891f9e6bafafb70 SET [use_profile]=[nat]

Customizing Log Config

Log file customizations are performed by editing the logfile.conf.xml file. Some of the things that you can change:

  • Log file rotation on SIGHUP (default = yes, recommended)
  • Log file location
  • Log file auto-rotation when log file hits a certain size
  • Which log levels and files get logged
  • Whether to log a channel's UUID (if available)

A discussion of how to customize what gets logged, by using the mappings, can be found in the console.conf.xml. The mod_console and mod_logfile use the same mechanism for customizing what gets logged. There is a nice write-up found in the comments of the console.conf.xml file.

Log Levels

Log levels are from most critical to least critical. "CONSOLE" is an exception to the rule as it is generally used for the purpose of filtering out log messages on the console. (?)

  • CONSOLE (Level 0)
  • ALERT (Level 1)
  • CRIT (Level 2)
  • ERR (Level 3)
  • WARNING (Level 4)
  • NOTICE (Level 5)
  • INFO (Level 6)
  • DEBUG (Level 7)

Logging UUIDs

If you wish to see the UUID of the channel that generated the log message you can add

<param name="uuid" value="true"/>

to a particular profile section in conf/autoloadconfigs/logfile.conf.xml . This will change the log output to include UUIDs when available. It will not put the uuid in the console (fs_cli).

Rotating Log Files

Log file rotation can be accomplished several ways. The simplest way is to send a HUP signal to FreeSWITCH.
NOTE: it is possible to disable log file rotation when receiving SIGHUP.

From FreeSWITCH CLI

From the FreeSWITCH CLI:

fsctl send_sighup

That's it!

From System CLI

From a typical Linux/Unix CLI:

kill -HUP `cat /usr/local/freeswitch/run/freeswitch.pid`

This allows the system administrator to schedule regular log rotations from a cron job if needed.

If you want to limit the number of retained log files you can add another cron job like this:

/usr/bin/find /usr/local/freeswitch/log -name "freeswitch.log.*" -mtime +31 -delete

This will delete any freeswitch.log.<timestamp> files older than 32 days, thereby keeping a month's worth of data. Note that on FreeBSD you need to quantify the +31 by telling it that number is in days eg. +31d.

By Log File Size

In logfile.conf.xml change this parameter:

<!--<param name="rollover" value="10485760"/>-->

The value is the number of bytes at which to start a new log file. Default is 10MB. Be sure to uncomment the line.

See Also