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.
Elixir Newsletter
Expand your skills

Download free e-books, watch expert tech talks, and explore open-source projects. Everything you need to grow as a developer - completely free.

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

Work with a team that keeps learning and building better software every day.

Related posts

Dive deeper into this topic with these related posts

No items found.

You might also like

Discover more content from this category

Manually update Apollo cache after GraphQL mutation

Ensuring that GraphQL mutations properly update your Apollo client's cache can be a bit tricky - here's how to manually control that.

How to check if a set contains exact values with Jest in JS?

TLDR: With jest-extended package you can write: expect([...set]).toIncludeSameMembers([value1, value2]);. If you are looking to a native, but longer solution scroll down a bit.

How to check if an Elixir map has a given key in a guard?

Today's Advent of Code puzzle inspired me to create this TIL. It may sound trivial, but in fact, it's tricky if you are unfamiliar with the nuances of guards' functioning.