Skip to content

Commit 9c18842

Browse files
ppkarwaszvy
authored andcommitted
Apply review for #2381
1 parent 1e2d99f commit 9c18842

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

src/changelog/.3.x.x/2408_remove_log4j_kubernetes.xml

-11
This file was deleted.

src/site/antora/modules/ROOT/examples/migrate-from-logback/MigrateFromLogback.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class MigrateFromLogback {
2626
try {
2727
// do something
2828
// tag::wrong[]
29-
} catch (Exception e) {
30-
logger.error("The foo process exited with an error: {}", e);
29+
} catch (Exception exception) {
30+
logger.error("The foo process exited with an error: {}", exception);
3131
}
3232
// end::wrong[]
3333
}
@@ -36,8 +36,8 @@ class MigrateFromLogback {
3636
try {
3737
// do something
3838
// tag::right[]
39-
} catch (Exception e) {
40-
logger.error("The foo process exited with an error.", e);
39+
} catch (Exception exception) {
40+
logger.error("The foo process exited with an error.", exception);
4141
}
4242
// end::right[]
4343
}

src/site/antora/modules/ROOT/pages/migrate-from-logback.adoc

+5-4
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ include::example$migrate-from-logback/MigrateFromLogback.java[tag=wrong]
120120
Log4j Core and Logback differ in the way they treat this statement:
121121
122122
Logback::
123-
Logback interprets the `e` argument as throwable and removes it from the list of parameters.
123+
Logback interprets the `exception` argument as throwable and removes it from the list of parameters.
124124
We end up with a parameterized statement with one placeholder, but zero parameters.
125125
The placeholder therefore remains as is:
126126
+
@@ -134,15 +134,15 @@ java.lang.RuntimeException: Message
134134
135135
Log4j Core::
136136
Log4j Core first looks for the parameters of the message.
137-
Since the format string has one placeholder, the `e` argument is interpreted as a parameter of the log message.
137+
Since the format string has one placeholder, the `exception` argument is interpreted as a parameter of the log message.
138138
The throwable associated to the log event is `null`, which results in a missing stack trace:
139139
+
140140
[source]
141141
----
142142
The foo process exited with and error: java.lang.RuntimeException: Message
143143
----
144144
145-
To fix this problem and obtain the same output in both backends, you should remove the placeholder from the format string:
145+
To fix this problem and get the same output in both backends, you should remove the placeholder from the format string:
146146
147147
[source,java,indent=0]
148148
----
@@ -164,4 +164,5 @@ java.lang.RuntimeException: Message
164164
As a temporary solution, the SLF4J-to-Log4j API bridges contain a special
165165
xref:manual/api.adoc#logger-message-factories[`MessageFactory`]
166166
that classifies trailing `Throwable` arguments in the same way Logback does.
167-
To use it, you need to set the xref:manual/systemproperties.adoc#log4j2.messageFactory[`log4j2.messageFactory`] configuration property to `org.apache.logging.slf4j.message.ThrowableConsumingMessageFactory`.
167+
To use it, you need to set the xref:manual/systemproperties.adoc#log4j2.messageFactory[`log4j2.messageFactory`] configuration property to `org.apache.logging.slf4j.message.ThrowableConsumingMessageFactory`.
168+
====

0 commit comments

Comments
 (0)