FreePBX syslog setup

Here is how to setup FreePBX to log to a syslog server. In my case I am using graylog with a syslog UDP input at port 1514.

Modify /etc/asterisk/logger_logfiles_custom.conf to add the desired items to be logged:

syslog.local0 => notice,warning,error,security

Modify /etc/rsyslog.conf and add the following line, matching the above destination:

local0.*                                  /var/log/asterisk/syslog

To forward to graylog I also uncommented the following in rsyslog.conf:

# ### begin forwarding rule ###
# The statement between the begin ... end define a SINGLE forwarding
# rule. They belong together, do NOT split them. If you create multiple
# forwarding rules, duplicate the whole block!
# Remote Logging (we use TCP for reliable delivery)
#
# An on-disk queue is created for this action. If the remote host is
# down, messages are spooled to disk and sent when it is up again.
$ActionQueueFileName fwdRule1 # unique name prefix for spool files
$ActionQueueMaxDiskSpace 1g   # 1gb space limit (use as much as possible)
$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
$ActionQueueType LinkedList   # run asynchronously
$ActionResumeRetryCount -1    # infinite retries if host is down
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
*.* @10.0.1.38:1514
# ### end of the forwarding rule ###

Finally restart the asterisk logger and rsyslog:

asterisk -rx "logger reload"
service rsyslog restart

The following resources were helpful in getting this setup:

http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/Monitoring_id264504.html

https://community.freepbx.org/t/is-it-possible-to-export-freepbx-logs-to-syslog/51676/4

Leave a Reply