0
votes

Umbrella apps are an interesting feature of Elixir, but I'm surprised the logging by default doesn't show which app is generating a log message. I'd like to add the umbrella app's name to the Logger metadata, but I'm not sure the best place to do that. Each app can configure the logger separately it seems and whitelist which metadata to show, but I'm not sure where to add the umbrella metadata

For example in apps/web/config/dev.exs I can put

config :logger, :console,
  metadata: [:umbrella_app]

But then I'm not finding a good place to add something like Logger.metadata(umbrella_app: :web) to populate the metadata.

1

1 Answers

1
votes

Try adding :application to metadata

config :logger, :console,
  format: "$metadata[$level] $message\n",
  metadata: [:application]

This will print message like this

application=app [level] Message