This is an automated email from the ASF dual-hosted git repository.

vy pushed a commit to branch doc/perf-main
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 9741e47395c125a9d257f6824c7617f880166605
Author: Volkan Yazıcı <vol...@yazi.ci>
AuthorDate: Tue May 14 15:15:19 2024 +0200

    Improve logger-name vs caller-class example
---
 .../modules/ROOT/partials/manual/layouts-location-information.adoc  | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git 
a/src/site/antora/modules/ROOT/partials/manual/layouts-location-information.adoc
 
b/src/site/antora/modules/ROOT/partials/manual/layouts-location-information.adoc
index ae6a3bb004..9235d0bf3e 100644
--- 
a/src/site/antora/modules/ROOT/partials/manual/layouts-location-information.adoc
+++ 
b/src/site/antora/modules/ROOT/partials/manual/layouts-location-information.adoc
@@ -24,6 +24,9 @@ Log4j takes a snapshot of the stack, and walks the stack 
trace to find the locat
 Note that _the caller class_ of the location information and _the logger name_ 
are two different things.
 In most setups just using _the logger name_ – which doesn't incur any overhead 
to obtain while logging! – is a sufficient and **zero-cost substitute for the 
caller class**.
 
+.Example demonstrating that the logger name can be a substitute for the caller 
name
+[%collapsible]
+=====
 [source,java]
 ----
 package com.mycompany;
@@ -42,6 +45,9 @@ public class PaymentService {
 
 }
 ----
+
+In the above example, if _the caller class_ (which is expensive to compute!) 
is omitted in the layout, the produced log line will still be likely to contain 
sufficient information to trace back the source by just looking at _the logger 
name_.
+=====
 ====
 
 Asynchronous loggers need to capture the location information before passing 
the log message to another thread; otherwise the location information will be 
lost after that point.

Reply via email to