Thanks! Usually I use the simple form like this, but the beauty of calling Logger.metadata() is that you can establish a context for upcoming log messages before execution is routed deep into functions. It’s especially valuable when you can send log messages with that metadata from functions that don’t have that data in scope. It was a mind-blowing experience for me to discover that Elixir did this – I remember so many code refactors done just to pass variables around for the sake of logging! So it’s frustrating that this isn’t working (yet) in my Mix tasks…
mix loadconfig will not affect running Logger. Unfortunately @fireproofsocks need to do it “manually” as IIRC there is no option to “reload” application environment.
No. I mean that changes in application environment will not be reflected in logger configuration unless explicitly done so. You need to use Logger.configure/1 to apply configuration.