概述:FreeSWITCH在大量呼叫的情况下,会产生大量的日志文件,占用许多磁盘空间,影响环境运行效率,因此需要进行日志管理。
以下简述方法。
以freeswitch的日志模块为基础,借助linux自启动、logrotate和cron来实现和完善。
一、FreeSWITCH控制台日志:
配置文件默认的路径: /usr/local/freeswitch/conf/autoload_configs/logfile.conf.xml
<configuration name="logfile.conf" description="File Logging">
<settings>
<!-- true to auto rotate on HUP, false to open/close -->
<param name="rotate-on-hup" value="true"/>
</settings>
<profiles>
<profile name="default">
<settings>
<!-- File to log to -->
<param name="logfile" value="/var/log/freeswitch/freeswitch.log"/>
<!-- At this length in bytes rotate the log file (0 for never) -->
<!-- <param name="rollover" value="1048576000"/>-->
<param name="rollover" value="120971520"/>
<!-- Maximum number of log files to keep before wrapping -->
<!-- If this parameter is enabled, the log filenames will not include a date stamp -->
<!-- <param name="maximum-rotate" value="32"/> -->
<!-- Prefix all log lines by the session's uuid -->
<param name="uuid" value="true" />
</settings>
<mappings>
<!--
name can be a file name, function name or 'all'
value is one or more of debug,info,notice,warning,err,crit,alert,all
Please see comments in console.conf.xml for more information
-->
<map name="all" value="console,debug,info,notice,warning,err,crit,alert"/>
</mappings>
</profile>
</profiles>
</configuration>
二、设置自启动
编辑/etc/rc.d/rc.local文件
echo "freeswitch stats start"
/usr/local/freeswitch/bin/top-stats &
/usr/local/freeswitch/bin/ctl-stats &
echo "freeswitch stats end"
FreeSWITCH状态日志
日志存储路径:
/var/log/freeswitch/ctl/ctl.log
top日志
日志存储路径:
/var/log/freeswitch/top/top.log