Where is a log file?

I have a logger in a Phoenix app:

defmodule Module1 do
  require Logger
  def method1 do

I can’t find the log file anywhere. Where is it?

This totally depends on your Logger configuration.

AFAIR in a default generated project in dev environment, Logger just emits to stdout.

1 Like

config :logger, :console,
format: “$time $metadata[$level] $message\n”,
metadata: [:request_id]

it doesn’t.

Have you actually activated the :console backend as well?

config :logger,
  backends: [:console]

Also make sure, that your :compile_time_purge_level is :debug. Last but not least, make sure that your function is actually called!


how to get it to log to a log file? or to a log file and console.

:backends takes a list, so just add another backend…

I’m not sure how exactly one could log into a file, since :logger-application itself does only have the :console backend (at least thats what the documentation says). So perhaps you’ll need to write your own backend. Or depending on the way you start your application in production, you will just keep it logging to stdout and let your systemd, openrc or whatever you are using care for the rest.

That is the logger_file_backend, just depend on that and follow its instructions (I.E. add it as a backend and configure what file you want it to go to and so forth).

There are backends for the system logger (if on linux this is often much smarter of an idea than a file logger), logging to databases, logging to other things, etc… etc…

ok, what are your thoughts in which you’re not sure?