For Java development, I use Slf4j and Logback.
Logger logger = LoggerFactory.getLogger(HelloWorld.class);
logger.debug("Hello world.");
How to use these two libs in Clojure programs? Majority of Clojure programming doesn't has .class concept (possible of course via AOT).
What do you use for logging in Clojure?
some excerpts from a one of my projects that uses log4j:
log.clj:
...
...
main.clj:
tools.logging. For details, refer to tools.logging vs clojure.contrib.logging
Look at this as well https://github.com/ptaoussanis/timbre . It looks very simple and nicely done.
Clojure comes with a logging core library in tools.logging. Add
[org.clojure/tools.logging "0.2.3"]
to your leiningenproject.clj
and run$lein deps
as usual.Once you
use
the library you can start logging awayNow you can also access the logger object and set the required fields, refer to the following article for this (written for the older contrib-lib but the same ideas apply):
http://www.paullegato.com/blog/setting-clojure-log-level/