Logging to file with function from where it is called and other information

I have an elixir umbrella project with three applications and I would like to setup proper logging to it.

I am able to log to a file after defining this in config.exs in one of my umbrella project (after first adding the LoggerFileBackend in dependencies as well):

config :logger,
  backends: [:console, {LoggerFileBackend, :debug_log}]

config :logger, :debug_log,
  path: "logs/debug.log",
  level: :debug

It is logging into this file I have setup in path from application when it is running. However, I would like to also prefix the file and function name to logged line. How can we add such configurations?

Currently it is logging it in following format:

15:32:01.838 [info] Running MyWeb.Endpoint with Cowboy using

It should be possible by providing a custom formatter, the documentation gives a very simple example:


PS: The caller information is in the metadata (if available at all)

1 Like