登录Clojure [英] Logging in Clojure
问题描述
对于Java开发,我使用Slf4j和Logback.
For Java development, I use Slf4j and Logback.
Logger logger = LoggerFactory.getLogger(HelloWorld.class);
logger.debug("Hello world.");
如何在Clojure程序中使用这两个库? Clojure编程的大多数没有.class概念(当然可以通过AOT进行.)
How to use these two libs in Clojure programs? Majority of Clojure programming doesn't has .class concept (possible of course via AOT).
您如何使用Clojure登录?
What do you use for logging in Clojure?
推荐答案
Clojure在 tools.logging .将[org.clojure/tools.logging "0.2.3"]
添加到您的leiningen project.clj
中,然后像往常一样运行$lein deps
.
Clojure comes with a logging core library in tools.logging. Add [org.clojure/tools.logging "0.2.3"]
to your leiningen project.clj
and run $lein deps
as usual.
一旦您use
该库,您就可以开始注销
Once you use
the library you can start logging away
(use 'clojure.tools.logging)
(warn "something bad happened")
现在,您还可以访问logger对象并设置必填字段,请参考以下文章(为较早的contrib-lib编写,但适用相同的思想):
Now 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/
这篇关于登录Clojure的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!