Skip to content

Instantly share code, notes, and snippets.

@ataggart
Last active June 16, 2020 14:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ataggart/ac208c289c5d01dacf3b4b341a1c37f0 to your computer and use it in GitHub Desktop.
Save ataggart/ac208c289c5d01dacf3b4b341a1c37f0 to your computer and use it in GitHub Desktop.
Example log4j2 project setup.
(defproject example "0.1.0"
:description "Example configuration for using log4j2 as the concrete logging
implementation. Libraries that depend on other well-known java
logging abstractions (e.g., SLF4J) will be logged with log4j2.
Also configures tools.logging to choose log4j2."
:dependencies [; Provide the log4j2 logging implementation:
[org.apache.logging.log4j/log4j-api "2.13.0"]
[org.apache.logging.log4j/log4j-core "2.13.0"]
; Provide log4j2 adapters for other java logging abstractions:
[org.apache.logging.log4j/log4j-jcl "2.13.0"]
[org.apache.logging.log4j/log4j-jul "2.13.0"]
[org.apache.logging.log4j/log4j-slf4j-impl "2.13.0"]
; Provide clojure logging abstraction:
[org.clojure/tools.logging "1.1.0"]]
:exclusions [; Exclude transitive dependencies on concrete implementations
; and adapters of the above java logging abstractions:
[ch.qos.logback/logback-classic]
[ch.qos.logback/logback-core]
[org.slf4j/jcl-over-slf4j]
[org.slf4j/jul-to-slf4j]
[org.slf4j/log4j-over-slf4j]
[org.slf4j/slf4j-nop]]
:jvm-opts [; Explicitly configure to use log4j2:
"-Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2-factory"]
:profiles {:dev {; Use a different log4j2 config in dev (defaults to log4j2.properties):
:jvm-opts "-Dlog4j.configurationFile=resources/log4j2-dev.properties"}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment