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.
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.
The default log file location is in the log subdirectory of the freeswitch install directory. On a typical Linux install this would be:
This location can be changed by editing the logfile.conf.xml file. Locate this line and modify accordingly:
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:
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 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)
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:
From System CLI
From a typical Linux/Unix CLI:
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:
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:
The value is the number of bytes at which to start a new log file. Default is 10MB. Be sure to uncomment the line.