spantaleev / matrix-docker-ansible-deploy

🐳 Matrix (An open network for secure, decentralized communication) server setup using Ansible and Docker
GNU Affero General Public License v3.0
4.82k stars 1.04k forks source link

Logging options #2769

Open alekslyse opened 1 year ago

alekslyse commented 1 year ago

In general, my question is, after searching is it any build options for enabling logging, and especially logging to a file? I do see the general domainname.config.log file, but that doesn't include an option for writing to a log file, but I see in the official documentation it's supported. How can I enable that on the ansible deployment?

spantaleev commented 1 year ago

Since systemd is a hard requirement for us, we just log to systemd-journald and disable all file logging so we don't do double logging.

As far as I know, we don't provide variables for letting you enable file logging in that log configuration file, but we may add some.

salleq commented 1 year ago

Being able to view logs with "docker logs" would be awesome. I'm using Dozzle for viewing container logs, so that would make things a lot easier. I guess it's the default JSON logging option on Docker ...?

spantaleev commented 1 year ago

We use systemd for starting Docker containers. Since systemd also does logging, having Docker also do it means we'd logging twice.

Furthermore, Docker log files tend to grow a lot and do not get rotated. With systemd-journald, throwing away old logs is handled automatically.


We're not opposed to modifying the playbook, so that the --log-driver option passed to each container is customizable (defaulting to none, as it is now). You may then be able to switch it to json-file and use Dozzle.

If you'd like to make a PR about this, here are a few notes:

  1. Each role should define its own matrix_COMPONENT_container_log_driver variable in its defaults/main.yml file with a default value of none and some nice comment saying that we're using systemd (and systemd-journald) and disabling Docker's logging mechanism intentionally. One can then adjust these variables on a per-component basis
  2. We may introduce a common matrix_container_log_driver variable in the matrix-base role's defaults/main.yml file (defaulting to none as well). All per-component variables can be set to matrix_container_log_driver from group_vars/matrix_servers. With that, one may only need to override a single variable (matrix_container_log_driver) and affect the log-driver for all components.

There are a lot of roles used by this playbook - both roles living inside this playbook (roles/custom) and roles being pulled from other sources (roles/galaxy). Adjusting all of these to make the log driver configurable will take quite a lot of work.