PatrickSachs

PatrickSachs

Hello there!

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.

This is my elixir version:

patrick@PATRICK:~$ elixir -v
Erlang/OTP 22 [erts-10.6.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Elixir 1.9.4 (compiled with Erlang/OTP 21)

This is my logger configuration:

config :logger,
  level: :debug

config :logger, :console,
  metadata: :all,
  level: :debug,
  format: {Sahnee.Logger, :format}

(The formater is not related to this, removing the custom formater yielded the same result)

If I launch my application with iex -S mix the logger is configured to level info:

iex(2)> require Logger
Logger
iex(3)> Logger.level
:info
iex(4)> Logger.debug("debug")
:ok
iex(5)> Logger.info("info")
:ok
15:49:45-875 [info]  #PID<0.1106.0>@.:5
 info
iex(6)> Logger.configure(level: :debug)
:ok
iex(7)> Logger.debug("debug2")         
:ok
15:49:56-202 [debug] #PID<0.1106.0>@.:7
 debug2

Can anyone point out why this is happening? No calls to Logger.configure are made in the application code.

Thank you for your time!
Patrick

Showing Posts 1 to 10

hauleth

hauleth

Are you using correct MIX_ENV?

PatrickSachs

PatrickSachs OP

I am not setting it explictly, just running iex -S mix. Should I be doing this? If so, where and how?

Checking the env tells me that its in dev mode: (which is what I want, I am on my development machine)

iex(3)> Mix.env
:dev
NobbZ

NobbZ

In which file is your logger config? And is that file actually loaded from your config.exs.

PatrickSachs

PatrickSachs OP

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:

iex(3)> Application.get_env :logger, :level
:info
iex(4)> Application.get_env :logger, :console
[metadata: :all, level: :debug, format: {Sahnee.Logger, :format}]

There also do not seem to be any other places where this config value is changed:

ityonemo

ityonemo

What happens if you switch from use Mix.Config to import Config?

PatrickSachs

PatrickSachs OP

Same result, all config values except this single one are applied:

iex(1)> Application.get_all_env :logger
[
  utc_log: false,
  translator_inspect_opts: [],
  compile_time_application: nil,
  handle_sasl_reports: false,
  truncate: 8096,
  compile_time_purge_level: :debug,
  level: :info, # <--
  sync_threshold: 20,
  discard_threshold_for_error_logger: 500,
  handle_otp_reports: true,
  discard_threshold: 500,
  console: [metadata: :all, level: :debug, format: {Sahnee.Logger, :format}],
  compile_time_purge_matching: [],
  backends: [:console],
  discard_threshold_periodic_check: 30000,
  translators: [
    {Plug.Cowboy.Translator, :translate},
    {Logger.Translator, :translate}
  ]
]

config.exs:

#use Mix.Config
import Config

import_config "sys.exs"

# snip...

sys.exs:

#use Mix.Config
import Config

# snip...

config :logger,
  level: :debug

config :logger, :console,
  metadata: :all,
  level: :debug,
  format: {Sahnee.Logger, :format}

# snip...
hauleth

hauleth

What is in # Snip parts? Are you sure that you do not set that key to different value later?

PatrickSachs

PatrickSachs OP

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)

hauleth

hauleth

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.

PatrickSachs

PatrickSachs OP

  • config.exs: config.exs - Pastebin.com
  • sys.exs: sys.exs - Pastebin.com
  • 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.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews