vy commented on code in PR #2645:
URL: https://github.com/apache/logging-log4j2/pull/2645#discussion_r1633691789
##########
src/site/antora/modules/ROOT/pages/manual/layouts.adoc:
##########
@@ -14,2120 +14,863 @@
See the License for the specific language governing permissions and
limitations under the License.
////
-= Layouts
-An Appender uses a Layout to format a LogEvent into a form that meets the
needs of whatever will be consuming the log event.
-In Log4j 1.x and Logback Layouts were expected to transform an event into a
String.
-In Log4j 2 Layouts return a byte array.
-This allows the result of the Layout to be useful in many more types of
Appenders.
-However, this means you need to configure most Layouts with a
-https://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html[`Charset`]
-to ensure the byte array contains correct values.
+= Layouts
-The root class for layouts that use a Charset is
-`org.apache.logging.log4j.core.layout.AbstractStringLayout` where the default
is UTF-8. Each layout that extends `AbstractStringLayout` can provide its own
default.
-See each layout below.
+An xref:manual/appenders.adoc[appender] uses a *layout* to encode a
link:../javadoc/log4j-core/org/apache/logging/log4j/core/LogEvent.html[`LogEvent`]
into a form that meets the needs of whatever will be consuming the log event.
+This page will try to answer following questions:
-A custom character encoder was added to Log4j 2.4.1 for the ISO-8859-1 and
US-ASCII charsets, to bring some of the performance improvements built-in to
Java 8 to Log4j for use on Java 7. For applications that log only ISO-8859-1
characters, specifying this charset will improve performance significantly.
+* xref:#concerns[What are some common concerns shared by all predefined
layouts?]
+* xref:#collection[Which layouts does Log4j provide?]
+* xref:#extending[How can you create custom layouts?]
-[#common-concerns]
+[#concerns]
== Common concerns
+This section introduces you to some common concerns shared by almost all
xref:#collection[predefined layouts] that you need to be aware of while using
them.
+
+[#charset]
+=== Character encoding
+
+All xref:#collection[predefined layouts] produce `String` that eventually get
converted into a `byte[]` using the
https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html[`Charset`]
configured.
+While doing so, they use `UTF-8` by default.
Review Comment:
Except `SerializedLayout` and `JsonTemplateLayout`, all layouts extend from
`AbstractStringLayout`, which defaults the `charset` to `UTF-8`.
`PatternLayout` deviates from this and uses the platform default due to
[LOG4J2-783](https://issues.apache.org/jira/browse/LOG4J2-783). I will rephrase
this as follows:
> While doing so, unless an explicit encoding configuration is stated, they
use `UTF-8` by default.
Fixed in 74a6ae462b201808bc06ca86888fc589b3adccd4.
For the record, `pattern-layout.adoc` was explicitly stating that `charset`
defaults to the platform default.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]