How can I disable logging of specific library?

I’m using GitHub - larskrantz/logger_papertrail_backend: A Papertrail backend for Elixir Logger.

From Elixir v1.15.0, it shows warnings like below.

warning: the log level :warn is deprecated, use :warning instead
  (logger 1.15.0) lib/logger.ex:1137: Logger.elixir_level_to_erlang_level/1
  (logger 1.15.0) lib/logger.ex:591: Logger.compare_levels/2
  (logger_papertrail_backend 1.1.0) lib/logger_papertrail_backend/logger.ex:60: LoggerPapertrailBackend.Logger.meet_level?/2
  (logger_papertrail_backend 1.1.0) lib/logger_papertrail_backend/logger.ex:33: LoggerPapertrailBackend.Logger.handle_event/2
  (stdlib 5.0.1) gen_event.erl:802: :gen_event.server_update/4
  (stdlib 5.0.1) gen_event.erl:784: :gen_event.server_notify/4
  (stdlib 5.0.1) gen_event.erl:786: :gen_event.server_notify/4
  (stdlib 5.0.1) gen_event.erl:526: :gen_event.handle_msg/6
  (stdlib 5.0.1) proc_lib.erl:241: :proc_lib.init_p_do_apply/3

Logger send :warn to logger backends instead of :warning.

This is reported as “warn” in Elixir’s logger backends for backwards compatibility reasons.

logger_papertrail_backend uses Logger.compare_level/2, so it inputs :warn to Logger.compare_level/2.

I want to disable that warning from logger_papertrail_backend.

How can I do that?


Per the Logger docs:

If you want to purge all log calls from an application named :foo and only keep errors from, you can set up two different matches:

config :logger,
  compile_time_purge_matching: [
    [application: :foo],
    [module: Bar, function: "foo/3", level_lower_than: :error]

So I assume for your purposes you could write something like:

config :logger, compile_time_purge_matching: [
  [application: :logger_papertrail_backend, level_lower_than: :error

Thank you!

1 Like