Skip to content

Commit abbd774

Browse files
committed
Improve 5min.adoc formatting
1 parent 210c9de commit abbd774

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/site/antora/modules/ROOT/pages/5min.adoc

+12-13
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ Let's try to walk through the most common ones.
152152
[#pitfal-toString]
153153
==== Don't use `toString()`
154154
155-
* [ ] `Object#toString()` is redundant in arguments
155+
* [ ] Don't use `Object#toString()` in arguments, it is redundant!
156156
+
157157
[source,java]
158158
----
159159
/* BAD! */ LOGGER.info("userId: {}", userId.toString());
160160
----
161161
162-
* [x] Underlying message type and layout will deal with arguments
162+
* [x] Underlying message type and layout will deal with arguments:
163163
+
164164
[source,java]
165165
----
@@ -169,18 +169,15 @@ Let's try to walk through the most common ones.
169169
[#pitfall-exception]
170170
==== Pass exception as the last extra argument
171171
172-
Using `Throwable#printStackTrace()` or `Throwable#getMessage()` while logging?
173-
Please, don't!
174-
175-
* [ ] Don't call `Throwable#printStackTrace()`.
172+
* [ ] Don't call `Throwable#printStackTrace()`!
176173
This not only circumvents the logging, but can also leak sensitive information!
177174
+
178175
[source,java]
179176
----
180177
/* BAD! */ exception.printStackTrace();
181178
----
182179
183-
* [ ] Don't use `Throwable#getMessage()`.
180+
* [ ] Don't use `Throwable#getMessage()`!
184181
This prevents the log event from getting enriched with the exception.
185182
+
186183
[source,java]
@@ -189,14 +186,15 @@ This prevents the log event from getting enriched with the exception.
189186
/* BAD! */ LOGGER.info("failed for user ID `{}`: {}", userId, exception.getMessage());
190187
----
191188
192-
* [ ] This bloats the log message with duplicate exception message
189+
* [ ] Don't provide both `Throwable#getMessage()` and `Throwable` itself!
190+
This bloats the log message with duplicate exception message.
193191
+
194192
[source,java]
195193
----
196194
/* BAD! */ LOGGER.info("failed for user ID `{}`: {}", userId, exception.getMessage(), exception);
197195
----
198196
199-
* [x] Pass exception as the last extra argument
197+
* [x] Pass exception as the last extra argument:
200198
+
201199
[source,java]
202200
----
@@ -209,8 +207,9 @@ This prevents the log event from getting enriched with the exception.
209207
210208
If you are using `String` concatenation while logging, you are doing something very wrong and dangerous!
211209
212-
* [ ] Circumvents the handling of arguments by message type and layout.
213-
More importantly, this code is prone to attacks!
210+
* [ ] Don't use `String` concatenation to format arguments!
211+
This circumvents the handling of arguments by message type and layout.
212+
More importantly, **this approach is prone to attacks!**
214213
Imagine `userId` being provided by user with the following content:
215214
`placeholders for non-existing args to trigger failure: {} {} \{dangerousLookup}`
216215
+
@@ -253,7 +252,7 @@ Maven::
253252
254253
<dependency>
255254
256-
<!-- The logging implementation (i.e., Log4j Core) -->
255+
<!-- Logging implementation (Log4j Core) -->
257256
<dependency>
258257
<groupId>org.apache.logging.log4j</groupId>
259258
<artifactId>log4j-core</artifactId>
@@ -449,7 +448,7 @@ Save the following XML document to `src/**test**/resources/log4j2-test.xml`:
449448
== What is next?
450449
451450
Installation::
452-
While shared dependency management snippets should get you going, it can also be challenging depending on your use case.
451+
While shared dependency management snippets should get you going, your case might necessitate a more intricate setup.
453452
Are you dealing with a Spring Boot application?
454453
Is it running in a Java EE container?
455454
Do you need to take into account other logging APIs such as JUL, JPL, JCL, etc.?

0 commit comments

Comments
 (0)