O'Reilly logo

Web Development with Clojure by Dmitri Sotnikov

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

Logging

Most real-world applications require some sort of logging functionality. At the very least we want to log any errors that happen in our application. This will allow us to go back and trace the cause of the errors if they happen in production.

Several logging options are available. In this section we’ll use the Timbre library.[51] First, we’ll need to include it in our project file:

picture-gallery-logging/project.clj
 
[com.taoensso/timbre ​"3.1.6"​]

Then we can start using it by requiring it in our namespace and calling the trace debug, info, warn, error, and fatal functions. Let’s add logging to the upload namespace and log errors if an exception occurs when we try to delete a file.

 
(​ns​ picture-gallery.routes.upload
 
(:require ...

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