Add Json logger

This commit is contained in:
andryyy
2017-05-06 23:42:18 +02:00
parent fa3a47fde5
commit d614aaf617
6 changed files with 81 additions and 13 deletions

View File

@@ -19,6 +19,7 @@ RUN apt-get install -y --no-install-recommends supervisor \
postfix-pcre \
syslog-ng \
syslog-ng-core \
syslog-ng-mod-redis \
ca-certificates \
gnupg \
python-gpgme \
@@ -29,11 +30,13 @@ RUN apt-get install -y --no-install-recommends supervisor \
RUN addgroup --system --gid 600 zeyple
RUN adduser --system --home /var/lib/zeyple --no-create-home --uid 600 --gid 600 --disabled-login zeyple
RUN touch /var/log/zeyple.log && chown zeyple: /var/log/zeyple.log
RUN sed -i -E 's/^(\s*)system\(\);/\1unix-stream("\/dev\/log");/' /etc/syslog-ng/syslog-ng.conf
RUN touch /etc/default/locale
COPY zeyple.py /usr/local/bin/zeyple.py
COPY zeyple.conf /etc/zeyple.conf
COPY supervisord.conf /etc/supervisor/supervisord.conf
COPY syslog-ng.conf /etc/syslog-ng/syslog-ng.conf
COPY postfix.sh /opt/postfix.sh
COPY whitelist_forwardinghosts.sh /usr/local/bin/whitelist_forwardinghosts.sh

View File

@@ -12,7 +12,7 @@ command=/opt/postfix.sh
autorestart=true
[program:postfix-maillog]
command=/bin/tail -f /var/log/zeyple.log /var/log/mail.log
command=/bin/tail -f /var/log/zeyple.log /var/log/combined.log
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0

View File

@@ -0,0 +1,31 @@
@version: 3.8
@include "scl.conf"
options {
chain_hostnames(off);
flush_lines(0);
use_dns(no);
use_fqdn(no);
owner("root"); group("adm"); perm(0640);
stats_freq(0);
bad_hostname("^gconfd$");
};
source s_src {
unix-stream("/dev/log");
internal();
};
destination d_combined { file("/var/log/combined.log"); };
destination d_redis {
redis(
host("redis-mailcow")
port(6379)
command("LPUSH" "POSTFIX_MAILLOG" "$(format-json time=\"$S_UNIXTIME\" priority=\"$PRIORITY\" program=\"$PROGRAM\" message=\"$MESSAGE\")\n")
);
};
filter f_mail { facility(mail) and not filter(f_debug); };
log {
source(s_src);
destination(d_combined);
filter(f_mail);
destination(d_redis);
};