Hello!
I’m deploying my Phoenix app using mix_systemd package, to run it as systemd unit file. The app’s runtime is in /srv/appname/current,
Problem: The app tries to create log files under /srv/appname/current/log/error.log and /srv/appname/current/console.log. I would like to configure it to create the log files under /var/log/appname.
I have no idea where this file creation comes from. My configuration does not contain logging to files:
It also happens when i just run mix phx.server in development mode. When i make the “log” dir unwritable (chmod 0 log) I get:
17:30:46.558 [error] Failed to open log file log/console.log with error permission denied
17:30:46.558 [error] Failed to open log file log/error.log with error permission denied
How can I figure out what is producing these messages? Too bad I can’t grep elixir binaries!
deps/lager/src/lager_file_backend.erl
131: ?INT_LOG(error, "Failed to open log file ~ts with error ~s", [Name, file:format_error(Reason)]),
692: "Failed to open log file " ++ TestLog ++ " with error permission denied",
739: "Failed to open log file " ++ TestLog ++ " with error permission denied",
lets investigate…
So lager is an erlang logger library pulled in by rabbitmq client package.
It needs to be configured in one of compiled config files, so config.exs or prod.exs for instance:
In the case of @marcin it is dependency of dependency (RabbitMQ). Hopefully in future lager will also be backed by logger so there will be only one place to configure logging (but we still will need to find a way to configure logger in development, but that is discussion for some other time).