Skip to content

Commit

Permalink
Update logging configuration to log4j2/slf4j2
Browse files Browse the repository at this point in the history
This ensures that log4j 1.x doesn't get pulled in by an older version of
the SLF4J implementation for log4j and updates the log4j.properties file
to the new format required by log4j2.

It also fixes a formatting issue where the use of Week Year "YYYY" vs
Year "yyyy" in the timestamp config resulted in a different year than
the current calendar year being printed in the logs.

Tested locally with lein run; logs appear as expected.

References:
https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/text/SimpleDateFormat.html
  • Loading branch information
respatialized committed Dec 28, 2021
1 parent 7c04352 commit 4dc3b97
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{:deps
{org.clojure/clojure {:mvn/version "1.10.0"}
org.clojure/tools.cli {:mvn/version "0.4.1"}
org.slf4j/slf4j-log4j12 {:mvn/version "1.7.32"}
org.apache.logging.log4j/log4j-slf4j-impl {:mvn/version "2.17.0"}
org.apache.logging.log4j/log4j-core
{:mvn/version "2.17.0"
:exclusions [javax.mail/mail
Expand Down
8 changes: 0 additions & 8 deletions resources/log4j.properties

This file was deleted.

13 changes: 13 additions & 0 deletions resources/log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# log4j.rootLogger=INFO, console
rootLogger.level = INFO

# log to the console
# log4j.appender.console=org.apache.log4j.ConsoleAppender
appender.console.type = Console
rootLogger.appenderRef.stdout.ref = STDOUT
# log4j.appender.console.Target=System.out
appender.console.name = STDOUT
# log4j.appender.console.layout=org.apache.log4j.PatternLayout
appender.console.layout.type = PatternLayout
# log4j.appender.console.layout.ConversionPattern=%d{[MM/dd/YYYY HH:mm:ss]} \u001b[1m%c{2}\u001b[0m :: %m%n
appender.console.layout.pattern = %d{[MM/dd/yyyy HH:mm:ss]} \u001b[1m%c{2}\u001b[0m :: %m%n

0 comments on commit 4dc3b97

Please sign in to comment.