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 ...

Get Web Development with Clojure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.