Elixir 1.19: Refactor Logger configuration to what Elixir 1.15+ expects

Elixir 1.19 started emitting warnings about our use of:
config :logger, :console and
config :logger, backends: []
which got split in 1.15 to :default_handler, :default_formatter, and
LoggerBackends.add(backend) respectively.

On Pleroma startup it is now necessary to add the additional logger
backends at runtime (done with configure_logger() in application.ex).
New config key :pleroma, :logger_backends: [] has replaced the older
backends array. The logger_backends package is now used to facilitate
usage of other logger backends besides the default one (:logger_std_h
from OTP).

Warnings were added to Pleroma startup to warn about the usage of
:logger, backends and additional logic was introduced to make addition
of ExSyslogger to admin's configuration less dumb.

Ref: https://hexdocs.pm/logger/1.15.0/Logger.html#module-backends-and-backwards-compatibility
This commit is contained in:
Phantasm 2026-01-10 16:42:09 +01:00 • committed by Phantasm
commit 926cad3a76
6 changed files with 55 additions and 22 deletions

View file

@ -132,11 +132,12 @@ config :pleroma, Pleroma.Web.Endpoint,
"SameSite=Lax"
]
# Configures Elixir's Logger
config :logger, backends: [:console]
# config :logger, :console has been changed in 1.15+ and split into
# :default_handler and :default_formatter. It started emitting warnings in 1.19.
# See https://hexdocs.pm/logger/1.19.0/Logger.html#module-backends-and-backwards-compatibility
config :logger, :default_handler, level: :debug
config :logger, :console,
level: :debug,
config :logger, :default_formatter,
format: "\n$time $metadata[$level] $message\n",
metadata: [:actor, :path, :type, :user]

View file

@ -36,7 +36,7 @@ config :pleroma, Pleroma.Emails.Mailer, adapter: Swoosh.Adapters.Local
# different ports.
# Do not include timestamps in development logs
config :logger, Logger.Backends.Console, format: "$metadata[$level] $message\n"
config :logger, :default_formatter, format: "$metadata[$level] $message\n"
# Set a higher stacktrace during development. Avoid configuring such
# in production as building large stacktraces may be expensive.

View file

@ -20,8 +20,7 @@ config :pleroma, Pleroma.Web.Endpoint,
config :phoenix, serve_endpoints: true
# Do not print debug messages in production
config :logger, Logger.Backends.Console, level: :info
config :logger, :console, level: :info
config :logger, :default_handler, level: :info
config :logger, :ex_syslogger, level: :info
# ## SSL Support

View file

@ -15,9 +15,9 @@ config :pleroma, Pleroma.Captcha,
method: Pleroma.Captcha.Mock
# Print only warnings and errors during test
config :logger, :console,
level: :warning,
format: "\n[$level] $message\n"
config :logger, :default_handler, level: :warning
config :logger, :default_formatter, format: "\n[$level] $message\n"
config :pleroma, :auth, oauth_consumer_strategies: []