Search⌘ K
AI Features

Step 4: Add Some Logging

Understand how to integrate logging into Elixir applications using the Logger module. Learn to configure compile-time and runtime log levels, and use logging functions for debug, info, warn, and error messages. This lesson helps you track significant events and maintain clarity in multi-process Elixir projects.

We'll cover the following...

Imagine a large Elixir application with dozens of processes potentially running across a number of nodes. We’d want a standard way to keep track of significant events as it runs. Enter the Elixir logger. The default mix.exs starts the logger for your application.

def application do 
 [
  extra_applications: [:logger] 
 ]
end

Logger

The logger supports four levels of message. In increasing order of severity, they are debug, info, warn, and error. We select the level of logging in two ways.

First, we can determine at compile time the minimum level of logging include. Logging below this level isn’t even compiled into the ...