logging: Log to systemd journal directly

While capturing stdout and stderr and automatically logging that to system
logging daemon provides basic information, a lot of information lost in the
process.

This change logs to systemd journal directly so that rich information such as
code file, code function, code line, etc, can be captured in a structured way.
To avoid double logging, discard stdout and stderr in the systemd unit file.

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2018-12-20 14:44:11 -08:00 committed by James Valleroy
parent dc7bd96ed7
commit f36753fcb8
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
3 changed files with 15 additions and 1 deletions

View File

@ -16,7 +16,7 @@
#
[Unit]
Description=Plinth Web Interface
Description=FreedomBox Service (Plinth)
Documentation=man:plinth(1)
After=network.target
@ -26,6 +26,8 @@ Restart=on-failure
ExecReload=/bin/kill -HUP $MAINPID
User=plinth
Group=plinth
StandardOutput=null
StandardError=null
[Install]
WantedBy=multi-user.target

1
debian/control vendored
View File

@ -38,6 +38,7 @@ Build-Depends: debhelper (>= 11~)
, python3-setuptools-git
, python3-yaml
, xmlto
Recommends: python3-systemd
Standards-Version: 4.2.1
Homepage: https://salsa.debian.org/freedombox-team/plinth
Vcs-Git: https://salsa.debian.org/freedombox-team/plinth.git

View File

@ -176,6 +176,17 @@ def configure_django():
}
}
try:
importlib.import_module('systemd.journal')
except ModuleNotFoundError:
pass
else:
logging_configuration['handlers']['journal'] = {
'class': 'systemd.journal.JournalHandler'
}
logging_configuration['root']['handlers'].append('journal')
templates = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',