File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,37 @@ The above approach is problematic given that applications often inadvertently pu
90
90
in multiple logging implementations as transitive dependencies. As such, it is
91
91
_ strongly_ advised that you set the system property.
92
92
93
+ ### Log4J2
94
+
95
+ A simple Log4j2 [ configuration] ( https://logging.apache.org/log4j/2.x/manual/configuration.html ) :
96
+
97
+ ``` properties
98
+ status = warn
99
+ monitorInterval = 5
100
+
101
+ appender.console.type = Console
102
+ appender.console.name = STDOUT
103
+ appender.console.layout.type = PatternLayout
104
+ appender.console.layout.pattern = %date %level %logger %message%n%throwable
105
+
106
+ rootLogger.level = info
107
+ rootLogger.appenderRef.stdout.ref = STDOUT
108
+ ```
109
+
110
+ * Note:* The above [ pattern] ( https://logging.apache.org/log4j/2.x/manual/layouts.html#Patterns )
111
+ explicitly uses ` %throwable ` so that ` clojure.lang.ExceptionInfo ` exceptions
112
+ will be printed with their data maps. If either ` %xThrowable ` (the default) or
113
+ ` %rThrowable ` is used, the data maps will not be printed.
114
+
115
+ ## FAQ
116
+
117
+ #### When logging an ` ex-info ` exception, why isn't the data map printed?
118
+
119
+ This is likely because the logging implementation is printing the contents of
120
+ ` Throwable.getMessage() ` , which returns just the message arg to ` ex-info ` .
121
+
122
+ Logging implementations that print the contents of ` toString() ` or use ` Throwable.printStackTrace(...) `
123
+ will end up printing the data map.
93
124
94
125
## Thanks
95
126
You can’t perform that action at this time.
0 commit comments