Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extra blank lines in Elixir logging?

Tags:

elixir

When I run my Elixir app with _build/prod/rel/foo/bin/foo foreground, the console logging has extra blank lines in it:

16:22:37.911 [info]  GET /

16:22:37.911 [info]  Sent 200 in 30µs

16:22:37.975 [info]  GET /favicon.ico

16:22:37.975 [info]  Sent 401 in 30µs

I'm using plug (no Phoenix) with Plug.Logger; the release was built with distillery. I've not done anything specific to configure logging.

How do I get rid of the blank lines?

like image 339
Roger Lipscombe Avatar asked Aug 21 '18 15:08

Roger Lipscombe


1 Answers

You can override the logger format in elixir, which by default contains a newline before and after every line. Override it by adding this to your config.exs:

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

More info about the default logger: https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/logger/lib/logger/formatter.ex

like image 119
fredrik Avatar answered Oct 24 '22 01:10

fredrik