Skip to content

refactor: fix application logging configuration to prevent disk fill #493

Description

@Neophytis

Problem

The current Monolog configuration in production generates excessive log volume:

  • Daily rotating logs (~70–100 MB/day): driven by security.DEBUG entries — Symfony's firewall logging authenticator checks on every request (120k+ entries/day). Root cause: the `main` handler in `config/packages/prod/monolog.yaml` is set to `level: debug`, which should never be the case in production. This is a config bug unrelated to Symfony version — present in 5.x through 7.x.

  • `prod.deprecations.log` (287 MB, unbounded): `config/packages/prod/deprecations.yaml` uses a plain stream handler with no rotation or deduplication. Currently flooded by Symfony 5.3 session storage deprecations firing on every request.

What a Symfony 6+ upgrade resolves

The session storage deprecations (`session.storage.factory.service`, `session.storage.native`, `session.storage.metadata_bag`) were removed in Symfony 6.0 — upgrading eliminates those specific messages entirely. The app session config will need to be updated to `session.storage.factory.native` to avoid a runtime break.

What still needs fixing regardless of Symfony version

  1. `config/packages/prod/monolog.yaml`: change the `main` handler from `level: debug` to `level: error` (or remove it — `fingers_crossed` + `file_log` already covers error logging and `main` is redundant).

  2. `config/packages/prod/deprecations.yaml`: switch from `type: stream` to `type: rotating_file` with `max_files: 3`.

  3. Docker best practice: replace file-based logging with stdout/stderr. Symfony's monolog supports `path: "php://stderr"` on the handler. In Docker, this lets the container runtime handle rotation via `--log-opt max-size` and `--log-opt max-file`. The current rox config has no stderr handler at all.

Priority

P2 — do not block cutover. Apply the quick monolog fixes (points 1 and 2) pre-cutover to avoid disk issues on the production server. The stdout/stderr refactor (point 3) can follow with the Symfony upgrade.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions