Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 804fa94
Showing
6 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/target | ||
/lib | ||
/classes | ||
/checkouts | ||
pom.xml | ||
*.jar | ||
*.class | ||
.lein-deps-sum | ||
.lein-failures | ||
.lein-plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# clojure-example-logback-integration | ||
|
||
Example of how to integrate logback into clojure.tools.logging. Also uses a log ns to delegate calls via macros so you can switch in timbre, etc. | ||
|
||
Important parts are in project.clj, src/logback.xml, and log.clj. | ||
|
||
## Usage | ||
|
||
Test with 'lein run' | ||
|
||
## License | ||
|
||
Copyright © 2012 Vaughn Dickson | ||
|
||
Distributed under the Eclipse Public License, the same as Clojure. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(defproject clojure-example-logback-integration "0.1.0-SNAPSHOT" | ||
:description "Simple integration of logback into clojure.tools.logging with macro-ed logs to swap in other logging libs" | ||
:url "http://example.com/FIXME" | ||
:license {:name "Eclipse Public License" | ||
:url "http://www.eclipse.org/legal/epl-v10.html"} | ||
:dependencies [[org.clojure/clojure "1.4.0"] | ||
[org.clojure/tools.logging "0.2.4"] | ||
[ch.qos.logback/logback-classic "1.0.7"]] | ||
:main clojure-example-logback-integration.core) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(ns clojure-example-logback-integration.core | ||
(:require [clojure-example-logback-integration.log :as log]) | ||
) | ||
|
||
(defn -main | ||
[& args] | ||
(log/debug "Test debug log") | ||
(log/info "Test info log") | ||
(log/error "Test error log") | ||
(try (throw (Exception. "Error, error")) | ||
(catch Exception e (log/error e "Test exception logging"))) | ||
(println "Check your logs!")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(ns clojure-example-logback-integration.log | ||
(:require [clojure.tools.logging :as log])) | ||
|
||
(defmacro debug [& args] | ||
`(log/debug (str ~@args))) | ||
|
||
(defmacro info [& args] | ||
`(log/info (str ~@args))) | ||
|
||
(defmacro warn [e & args] | ||
`(log/warn (str ~@args) ~e)) | ||
|
||
(defmacro warn [& args] | ||
`(log/warn (str ~@args))) | ||
|
||
(defmacro error [& args] | ||
`(log/error (str ~@args))) | ||
|
||
(defmacro error [e & args] | ||
`(log/error ~e (str ~@args))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<configuration debug="false"> | ||
<appender name="MAIN" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %-10contextName %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<logger name="clojure-example-logback-integration" level="DEBUG"/> | ||
|
||
<root level="INFO"> | ||
<appender-ref ref="MAIN"/> | ||
</root> | ||
</configuration> |