Commit 23307b63 authored by jaywink's avatar jaywink

Allow configuring logging target and Loggly

Allow configuring logging to syslog and through there to Loggly.
parent b8f9ca3e
......@@ -46,3 +46,15 @@ socialhome_email_from: "noreply@socialhome.local"
# Statistics
socialhome_statistics: true
# Logging
# Set to either file or syslog
socialhome_log_target: file
# Only used if above is syslog
# Set to either DEBUG, INFO, WARNING, ERROR
socialhome_syslog_level: INFO
# Loggly
# Only relevant if socialhome_log_target is syslog
socialhome_loggly: false
socialhome_loggly_token:
......@@ -3,3 +3,5 @@
service: name=apache2 state=restarted
- name: restart circus
service: name="{{ socialhome_domain }}-circus" state=restarted
- name: restart rsyslog
service: name=rsyslog state=restarted
---
- name: Rsyslog TLS package
apt: name=rsyslog-gnutls state=present
- name: Configure rsyslog for Loggly
template:
src: 22-loggly.conf
dest: /etc/rsyslog.d/22-loggly.conf
notify:
- restart rsyslog
- name: Configure rsyslog for Django
template:
src: 21-django.conf
dest: /etc/rsyslog.d/21-django.conf
notify:
- restart rsyslog
- name: Max message size of rsyslog
lineinfile:
dest: /etc/rsyslog.conf
state: present
line: '$MaxMessageSize 64k'
insertbefore: BOF
notify:
- restart rsyslog
- name: Create ca.d directory
file:
path: /etc/rsyslog.d/keys/ca.d
state: directory
- name: Copy Loggly cert
template:
src: loggly.crt
dest: /etc/rsyslog.d/keys/ca.d/logs-01.loggly.com_sha12.crt
notify:
- restart rsyslog
......@@ -11,3 +11,5 @@
environment:
DJANGO_SETTINGS_MODULE: config.settings.production
- include: circus_ini.yaml
- include: loggly.yaml
when: socialhome_loggly and socialhome_log_target == "syslog"
#provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514
#Add a tag for Django events
$template LogglyFormatDjango,"<%pri%>%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% %procid% %msgid% [{{ socialhome_loggly_token }}@41058 tag=\"{{ socialhome_domain }}\"] %msg%\n"
local7.* @@logs-01.loggly.com:514;LogglyFormatDjango
local7.* ~ #discards the messages so they don't end up in /var/log/syslog
##########################################################
### RsyslogTemplate for Loggly ###
##########################################################
# Setup disk assisted queues
$WorkDirectory /var/spool/rsyslog # where to place spool files
$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
#RsyslogGnuTLS
$DefaultNetstreamDriverCAFile /etc/rsyslog.d/keys/ca.d/logs-01.loggly.com_sha12.crt
$ActionSendStreamDriver gtls
$ActionSendStreamDriverMode 1
$ActionSendStreamDriverAuthMode x509/name
$ActionSendStreamDriverPermittedPeer *.loggly.com
#################END CONFIG FILE#########################
......@@ -34,8 +34,9 @@ DJANGO_ADMIN_MAIL={{ socialhome_admin_mail }}
SOCIALHOME_ROOT_PROFILE={{ socialhome_root_profile }}
{% endif %}
SOCIALHOME_LOG_TARGET={{ socialhome_log_target }}
SOCIALHOME_LOGFILE=/home/{{ socialhome_os_user }}/logs/socialhome.log
SOCIALHOME_LOGFILE_FEDERATION=/home/{{ socialhome_os_user }}/logs/socialhome-federation.log
SOCIALHOME_SYSLOG_LEVEL={{ socialhome_syslog_level }}
{% if socialhome_debug %}
DJANGO_DEBUG=True
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment