Best way to manage logs in self-hosted deployments

What are people’s thoughts on the best way to manage all the logs a self-hosted Bitwarden deployment creates?

It’s just a small family deployment – and I’d rather not keep logs much older than a week or so.

Thanks.

To just keep the 5 most recent log files for each container and keep each log file down to 10mb each, I added max-file: “5” and max-size: “10m” for each container in bwdata/docker/docker-compose.override.yml.

My full bwdata/docker/docker-compose.override.yml:

services:
  mssql:
    logging:
      options:
        max-file: "5"
        max-size: "10m"

  web:
    logging:
      options:
        max-file: "5"
        max-size: "10m"

  attachments:
    logging:
      options:
        max-file: "5"
        max-size: "10m"

  api:
    logging:
      options:
        max-file: "5"
        max-size: "10m"

  identity:
    logging:
      options:
        max-file: "5"
        max-size: "10m"

  sso:
    logging:
      options:
        max-file: "5"
        max-size: "10m"

  admin:
    logging:
      options:
        max-file: "5"
        max-size: "10m"

  icons:
    logging:
      options:
        max-file: "5"
        max-size: "10m"

  notifications:
    logging:
      options:
        max-file: "5"
        max-size: "10m"

  events:
    logging:
      options:
        max-file: "5"
        max-size: "10m"

  nginx:
    volumes:
      - /etc/localtime:/etc/localtime:ro
    logging:
      options:
        max-file: "5"
        max-size: "10m"

p.s. The localtime bit is so the timestamps in the nginx log files are in my local time instead of UTC.

Perfect. Thanks!

Does this actually work for you guys?
I added the following to all services in my docker-compose.override.yml, restarted bitwarden and docker but the existing logs do not appear to get cleaned up:

Any ideas appreciated.

My apologies. What I posted, in terms of docker compose additions, is actually for docker logging. That is what was taking up the most space on my system. The services logs roll in at under 100MB after years.

Log rotations for services (other than nginx) is governed by a single configuration in bwdata/env/global.override.env:

globalSettings__logRollBySizeLimit=5242880

There is only a file size limitation, so keeping x number of days worth etc would have to be handled by a custom logrotate or a script, crontab, etc using something like:

find bwdata/logs/ -type f -mtime +90 -exec rm {} \;

Which would remove any files in any of the log directories older than 90 days, for example.

nginx appears to be handled by Bitwarden’s own logrotate.sh script which rotates logs daily and keeps ~32 days worth.