Integrating OTP handler for logging to file

(Decided to split off from this post to be in proper forum)

Hi – I’m attempting to use the OTP standard logger to log messages to file. I’ve so far been successful in generating the log file, but none of my log messages get written to the file. I mostly followed the Logger documentation

Unsure if I need to also adjust the backends config value. Are there any glaring errors in my config?

# runnable.exs
def start(_type, _args) do
    :logger.add_handlers(:runnable)"Starting application...")

    children = [
    Supervisor.start_link(children, strategy: :one_for_one)

# config.exs
config :logger,
  backends: [:console]

config :logger, :console,
  level: :info

config :runnable, :logger,
    {:handler, :default, :logger_std_h,
      %{level: :info,
        %{file: 'test.log'}

You should use different name for your handler than :default as this one is handled in “special” way. You can check the configuration via :logger.get_handler_config() and see that for example it uses filter_default: :stop and have bunch of filters set by default. So I would highly suggest to use name in form YourApp.Logger to avoid any possible name conflicts.