matrix-docker-ansible-deploy icon indicating copy to clipboard operation
matrix-docker-ansible-deploy copied to clipboard

Logging options

Open alekslyse opened this issue 1 year ago • 3 comments

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?

alekslyse avatar Jun 28 '23 02:06 alekslyse

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.

spantaleev avatar Jun 28 '23 05:06 spantaleev

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 ...?

salleq avatar Sep 16 '23 08:09 salleq

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.

spantaleev avatar Sep 16 '23 08:09 spantaleev