quatermain

quatermain

Phoenix logger format

Hello,
I have this in prod.exs:

config :logger,
      level: :info,
      backends: [:console],
      compile_time_purge_level: :info,
      metadata: [:request_id],
      format: "$time $metadata[$level] $metadata[$request_id] $message\n"

and I still get this like logger output:

13:55:01.183 [info]  GET /sessions/new
13:55:01.185 [info]  Sent 200 in 1ms

I use this:

Hex:    0.18.2
Elixir: 1.7.4
OTP:    21.1.1
distillery: 1.5.5
phoenix: 1.4.0

Any idea where can be problem?

First Post!

mudasobwa

mudasobwa

Creator of Cure

You should rebuild phoenix for this to take effect (mix deps.clean.)

Most Liked

voughtdq

voughtdq

This happens to me so often and I always forget. Basically, the format is specific to the backend, so you have to add this to your config:

config :logger, :console,
      metadata: [:request_id],
      format: "$time $metadata[$level] $metadata[$request_id] $message\n"

Edit: and IIRC $metadata is just a list of the metadata variables. So you can’t “access” it. So you’re format probably should be: format: "$time $metadata[$level] $message\n" or you’ll just repeat $metadata twice (and I don’t think $request_id will expand to anything at all)

Last Post!

gmile

gmile

These lines are coming from Plug.Logger, see this. To remove them, add log: debug to the plug init in your endpoint.ex like this:

plug Plug.Logger, log: :debug

Those log lines will now only appear in development.

Where Next?

Popular in Questions Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New

Other popular topics Top

joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
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 44167 214
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42576 114
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement