O'Reilly logo

Adopting Elixir by Jose Valim, Bruce Tate, Ben Marx

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Logs and Errors

The first defense against bugs is application-specific information, and the best way to acquire that is via old-fashioned logging. Elixir comes with the creatively named built-in Logger for logging messages. The word “messages” matters, because Logger was designed with a focus on text-based reports and not structured data.

Logger contains four severity levels. From least to most severe, they are :debug, :info, :warn, and :error. When you configure Logger for the :info level, it will log :info and everything more severe, including :warn and :error messages. A developer can log any message at any time through the Logger API, like this:

 require​ Logger
 Logger.debug ​"​​hello"

Logger also handles errors for all processes that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required