rokku3kpvc

rokku3kpvc

Elixir OTP 24 doesn't apply custom Logger backend

I have an umbrella application which has logger configuration in the root config.exs file:

config :logger,
  compile_time_purge_level: :debug,
  backends: [
    {LoggerFileBackend, :backends_log}
  ]

config :logger, :backends_log,
  path: "path/to/awesome.log",
  level: :debug,
  metadata: :all

After updating OTP from 22 to 24 version (elixir 1.12.3, erlang 24.1), backends_log is not starting and all logs are going to STDOUT with default console backend.
But configuration is still same:

Application.get_all_env(:kernel)
=> [
  logger: [
    {:handler, :default, :logger_std_h,
     %{
       config: %{type: :standard_io},
       formatter: {:logger_formatter,
        %{legacy_header: true, single_line: false}}
     }}
  ],
  logger_sasl_compatible: false,
  logger_level: :notice,
  shell_docs_ansi: :auto
]

Application.get_all_env(:logger)
=> [
  handle_sasl_reports: true,
  discard_threshold: 5000,
  compile_time_purge_matching: [],
  sync_threshold: 10000,
  utc_log: false,
  console: [],
  backends_log: [path: "path/to/awesome.log", level: :debug, metadata: :all],
  start_options: [],
  pdu_format_reviewer_error_count: [level: :error],
  compile_time_application: nil,
  backends: [
    {LoggerFileBackend, :backends_log}
  ],
  discard_threshold_periodic_check: 30000,
  translators: [
    {Plug.Cowboy.Translator, :translate},
    {Logger.Translator, :translate}
  ],
  compile_time_purge_level: :debug,
  truncate: 8096,
  log_counter: [level: :debug],
  handle_otp_reports: true,
  discard_threshold_for_error_logger: 500,
  translator_inspect_opts: []
]

:logger.get_primary_config()
=> %{
  filter_default: :log,
  filters: [process_disabled: {&Logger.Filter.process_disabled/2, []}],
  level: :debug,
  metadata: %{}
}

I can fix this problem with Runtime Configuration

    Logger.add_backend({LoggerFileBackend, :backends_log})
    Logger.configure_backend(
       {LoggerFileBackend, :backends_log},
       path: "path/to/awesome.log",
       level: :debug,
       metadata: :all
    )
    Logger.remove_backend(Logger.Backends.Console)

but I think Application Configuration is more proper way.

How should I fix this problem?

First Post!

hauleth

hauleth

Did the :logger application started? That may be the source of the problem, as kernel.logger is updated only when Logger application starts. Just beware, that logger configuration is not applied during compilation, it is only runtime thing.

Where Next?

Popular in Questions Top

New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31194 112
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31307 143
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54250 245
New

We're in Beta

About us Mission Statement