I am currently facing an issue with the logger.
At some point it started logging at info level only despite being configured to log at debug level. The interesting thing is that it used to work fine before. I am not sure what broke it, since I wasn’t working on the project for over a month. So it may have been a breaking Elixir update or a lack of knowledge by making a bad change on my part.
My config is in a file called sys.exs. This file is loaded in the first line of my config.exs. The file also contains several other options (such as the Ecto Repo, etc.) which are working.
use Mix.Config
import_config "sys.exs"
Interestingly enough, all values other than the log level are also loaded:
Unfortunately not, no. I posted a screenshort earlier where I searched for :logger in my entire project. The term has only three occurences: Two for the two config entries posted above and one in extra_application to actually start the logger (I think, been a while since I set it up).
If you absolutely want to see the full config I can post it, but since its roghly 150 lines I’d prefer to spare you the wall of text. (Also worried about forgetting to remove a production secret :D)
Just use paste bin. However it is hard to tell you where the bug can be. Unfortunately logger isn’t external application so it isn’t that simple to edit it.
Try searching for Logger, maybe there is some rouge call that changes it in the application itself.
local.exs: I cannot post this file under any circumstances since its only purpose is to store secrets that should not be commited to git. (Neither :logger nor Logger are used or configured within this file.)
Try searching for Logger , maybe there is some rouge call that changes it in the application itself.
Which terms would be of interest to search? It’s a large application (by my standards) so there are hundrets of Logger calls. Logger.configure is not called. Asides from normal log statements a lot of metadata is being set, but no metadata entry is called level or contains the value info if that could be a culprit.
Thanks to everyone who has posted so far. This is probably going to be an embarassing “oops” kind of mistake that I made, but the source of it eludes me.
import Config
# Print only warnings and errors during test
config :logger,
backends: [:console],
level: :warning
and yet the Logger.info() lines in my app still print out to console in ‘mix test’.
Now I know that this config is actually being read, because when I change it to
This actually works in removing the info level log lines.
I have searched the project, and there doesn’t seem to have any calls to Logger.configure/1 that would be setting the level back. Unless it is somehow being set in my dependencies?
Anyhow, don’t want to hijack this thread. Just wanted to know we have a shared issue with Logger acting funny.
Something else to watch, if you’re using escript: The config/*.exs settings get built into the escript binary when it’s compiled. If you change them, you need to recompile the binary for the change to take effect.