Cannot start application Logger

Background

I have an app that I am trying to start via iex -S mix, but I am unable to.

Error

Upon running the previous command I get the following error:

** (Mix) Could not start application logger: Logger.App.start(:normal, []) returned an error: shutdown: failed to start child: Logger.BackendSupervisor
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, {{{:case_clause, {:EXIT, {:undef, [{LoggerFileBackend, :init, [{LoggerFileBackend, :deals_logger}], []}, {:gen_event, :server_add_handler, 4, [file: 'gen_event.erl', line: 473]}, {:gen_event, :handle_msg, 6, [file: 'gen_event.erl', line: 318]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}]}}}, [{Logger.Watcher, :init, 1, [file: 'lib/logger/watcher.ex', line: 28]}, {:gen_server, :init_it, 2, [file: 'gen_server.erl', line: 374]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 342]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}]}, {:child, :undefined, {LoggerFileBackend, :deals_logger}, {Logger.Watcher, :start_link, [{Logger, {LoggerFileBackend, :deals_logger}, {LoggerFileBackend, :deals_logger}}]}, :transient, 5000, :worker, [Logger.Watcher]}}}
            (logger) lib/logger/backend_supervisor.ex:14: anonymous fn/2 in Logger.BackendSupervisor.start_link/1
            (elixir) lib/enum.ex:1940: Enum."-reduce/3-lists^foldl/2-0-"/3
            (logger) lib/logger/backend_supervisor.ex:13: Logger.BackendSupervisor.start_link/1
            (stdlib) supervisor.erl:379: :supervisor.do_start_child_i/3
            (stdlib) supervisor.erl:365: :supervisor.do_start_child/2
            (stdlib) supervisor.erl:349: anonymous fn/3 in :supervisor.start_children/2
            (stdlib) supervisor.erl:1157: :supervisor.children_map/4
            (stdlib) supervisor.erl:315: :supervisor.init_children/2
            (stdlib) gen_server.erl:374: :gen_server.init_it/2
            (stdlib) gen_server.erl:342: :gen_server.init_it/6
            (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

My project has several dependencies, some of them from private git repositories that also use logger, but I never had this issue and I added logger to the extra_applications part of the mix.exs file.

extra_applications: [:logger, :runtime_tools, :some_app]

Versions:

elixir 1.8.1-otp-21
erlang 21.2

What could be causing this?

1 Like

This is not part of the regular :logger application. Perhaps you are missing :logger_file_backend in your list of dependencies? Or you simply need to remove that backend from your configuration.

2 Likes

I have also improved the error in master. For an invalid backend OMG, it will now say:

** (Mix) Could not start application logger: Logger.App.start(:normal, []) returned an error: shutdown: failed to start child: Logger.BackendSupervisor
    ** (EXIT) an exception was raised:
        ** (RuntimeError) EXIT when installing backend OMG: an exception was raised:
    ** (UndefinedFunctionError) function OMG.init/1 is undefined (module OMG is not available)
        OMG.init(OMG)
        (stdlib) gen_event.erl:473: :gen_event.server_add_handler/4
        (stdlib) gen_event.erl:318: :gen_event.handle_msg/6
        (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
5 Likes