Silent app startup

I’m writing a mix task that needs part of my app to be started.

But when I use Mix.Task.run("app.start") or Application.ensure_all_started(:my_app), I have tons of info logs like this:

16:02:55.606 [info] Application lager started on node nonode@nohost
16:02:55.624 [info] Application gpb started on node nonode@nohost
16:02:55.624 [info] Application exprotobuf started on node nonode@nohost
16:02:55.640 [info] Application eex started on node nonode@nohost
16:02:55.661 [info] Application mime started on node nonode@nohost
16:02:55.664 [info] Application plug_crypto started on node nonode@nohost
16:02:55.678 [info] Application telemetry started on node nonode@nohost
16:02:55.680 [info] Application plug started on node nonode@nohost

Any way to silent this?

Already tried an experimental cocktail with multiple combinations of following commands. Not working … :confused:

Mix.shell(Mix.Shell.Quiet)
Logger.disable(self())
Logger.remove_backend(:console)
Mix.Task.run("app.start")

Can’t believe Logger.remove_backend(:console) doesn’t help. I guess Logger is successfully disabled and these logs were written by lager.

2 Likes

Maybe?
What do you think I should do?

I’m a bit confused between logger and lager, it reminds me of the dark ages of Java (log4j, common-logging :scream:)

:lager - popular third party logger in erlang
:logger - erlangs new logger api (newer than :lager)
Logger - elixir’s logger api (in recent versions of elixir mostly backed by erlangs :logger)

3 Likes

It was indeed Lager, thank you @fuelen!

I was able to get rid of most logs with :

config :lager,
  handlers: [
    lager_console_backend: [{:level, :critical}]
  ]

and then Logger.remove_backend(:console) removed the few extra logs remaining!

3 Likes