Using Logger.info and Logger.debug in ExUnit tests

Article autor
September 9, 2025
Using Logger.info and Logger.debug in ExUnit tests
Elixir Newsletter
Join Elixir newsletter

Subscribe to receive Elixir news to your inbox every two weeks.

Oops! Something went wrong while submitting the form.

Table of contents

By default in the test env, Phoenix doesn't show Logger.debug/Logger.info outputs in the console.

Logger provides 4 printing levels:

  • info (allows errors, warns, debugs, infos)
  • debug (allows errors, warns, debugs)
  • warn (allows errors, warns)
  • error (allows errors)

By default the :warn level is turned on. It means that only Logger.warn and Logger.error is printed to the output.

If you'd like to use another two, go to your config/test.exs file and you'll probably see:

# Print only warnings and errors during test
config :logger, level: :warn

Just change the line to the proper level (:debug or :info), and you're ready to go:

# Print all (errors, warnings, debugs and infos) during tests
config :logger, level: :info

Related posts

Dive deeper into this topic with these related posts

No items found.

You might also like

Discover more content from this category

How to contain a fixed positioned element

It's easy to contain absolute positioned elements. Things get a little trickier when you want to contain a fixed positioned element without changing its stylings.

Implicit try in Elixir

In the world of Elixir programming, there are numerous features and syntactic constructs that contribute to the language's elegance and expressiveness. One such hidden gem is the concept of "implicit try".

Multiple pattern-matching concatenations for the single string

Pattern-matching is one of the finest elixir-lang features. Whoever knows the power of this tool once, will want to use it forever.