vrod

vrod

Hot reloading to add Logging?

I am trying to understand better the Elixir Logger. I have read Compile time purging of logger levels - #12 by aseigo and Logging from within Remote Session - #6 by ityonemo
I have an app where I did something like:

# runtime.exs
config :logger, :console,
  level: System.get_env("LOG_LEVEL", "info") |> String.to_existing_atom()

but now I am thinking this is not possible like I hoped. I read about the option for :compile_time_purge_matching… so if I have

config :logger,
  backends: [:console],
  compile_time_purge_matching: [
    [level_lower_than: :info]
  ]

in my config.exs but I have log level of :debug in runtime.exs, there are no more debug messages visible because they have been removed during compile.

One problem I noticed on a built release is that when I remote attach to a running app, I still see debug messages even when the level is :info. I think this maybe has something to do because my process in remote iex is different that the process of the running app (?) but this is just my guess – I really don’t understand why.

The other example I wanted to see was how to hot reload a module to include logging statements? If I am remote into running app with all debug statements removed at compile time, how could I add debugging back in so I can debug running production instance?

Thank you for your wisdom. I know this is a complex topic but I am trying to get more infos for how to approach.

Where Next?

Popular in Questions Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44265 214
New

We're in Beta

About us Mission Statement