#log4-clj-layout
A flexible log4j layout for Clojure via slf4j.
Put a log4j.properties on your classpath (resources/log4j.properties), add
any custom key-vals to the output, and set the log formatting function
(defaults to #'log4-clj-layout.layout/pprint-format).
log4j.rootCategory=INFO,STDOUT
log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
log4j.appender.STDOUT.layout=log4_clj_layout.layout.Layout
log4j.appender.STDOUT.layout.UserFields=field1:val1,field2:val2
log4j.appender.STDOUT.layout.FormatFn=pprint-formatOr you can write and use your own formatting function.
log4j.rootCategory=INFO,STDOUT
log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
log4j.appender.STDOUT.layout=log4_clj_layout.layout.Layout
log4j.appender.STDOUT.layout.UserFields=field1:val1,field2:val2
log4j.appender.STDOUT.layout.FormatFn=your-namespace.core/fancy-formatSome keys emitted by default such as :file, :method, :class,
etc., may clash with keys you wish to emit from software. A prefix to
the default root keys can be set so as not to conflict with
application keys.
log4j.appender.STDOUT.layout.RootKeyPrefix=javaYou can set $APPLICATION and/or $TEAM in your environment. This
will override any properties set in log4j.properties.
An example of Logging Hell™ dependencies:
(def slf4j-version "1.7.25")
(defproject testing "0.1.0-SNAPSHOT"
:main testing.core
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/tools.logging "0.3.1"]
[cheshire "5.5.0"]
[clj-time "0.11.0"]
;; SLF4J is a common interface to any logger implementation.
[org.slf4j/slf4j-api ~slf4j-version] ; The interface
;; Redirect logs into SLF4J from various places
[org.slf4j/jul-to-slf4j ~slf4j-version]
[org.slf4j/jcl-over-slf4j ~slf4j-version]
;; Use Log4J as the implementation for the SLF4J interface.
[org.slf4j/slf4j-log4j12 ~slf4j-version]
;; Actually include Log4J
;; Log4J is configured separatly via resources/log4j.properties
[log4j/log4j "1.2.17"
:exclusions [javax.mail/mail javax.jms/jms
com.sun.jmdk/jmxtools com.sun.jmx/jmxri]]
[log4-clj-layout "0.2.0-SNAPSHOT"]])Copyright © 2016 uSwitch Limited.
Distributed under the Eclipse Public License, the same as Clojure.