From 3d6072336037bc98f96f02ddec95a014545ed663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mal=C3=A9=C5=99?= Date: Wed, 5 Feb 2025 15:49:09 +0100 Subject: [PATCH] Brief review for the Logging guide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Maléř --- docs/src/main/asciidoc/logging.adoc | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/docs/src/main/asciidoc/logging.adoc b/docs/src/main/asciidoc/logging.adoc index 1a50a862618b0..ca4362f0bd7c7 100644 --- a/docs/src/main/asciidoc/logging.adoc +++ b/docs/src/main/asciidoc/logging.adoc @@ -169,9 +169,11 @@ class SimpleBean { <1> The fully qualified class name (FQCN) of the declaring class is used as a logger name, for example, `org.jboss.logging.Logger.getLogger(SimpleBean.class)` will be used. <2> In this case, the name _foo_ is used as a logger name, for example, `org.jboss.logging.Logger.getLogger("foo")` will be used. -NOTE: The logger instances are cached internally. +[NOTE] +==== +The logger instances are cached internally. Therefore, when a logger is injected, for example, into a `@RequestScoped` bean, it is shared for all bean instances to avoid possible performance penalties associated with logger instantiation. - +==== == Use log levels @@ -530,12 +532,9 @@ For details about its configuration, see the xref:#quarkus-core_section_quarkus- === Socket log handler -This handler will send the logs to a socket. -It is disabled by default, so you must first enable it. -When enabled, it sends all log events to a socket, for instance to a Logstash server. - -This will typically be used in conjunction with the `quarkus-logging-json` extension so send logs in ECS format to an Elasticsearch instance. -An example configuration can be found in the xref:centralized-log-management.adoc[Centralized log management] guide. +This handler sends logs to a socket. +Socket log handler is disabled by default; enable it to use it. +When enabled, it sends all log events to a socket, such as a Logstash server. * A global configuration example: + @@ -545,6 +544,9 @@ quarkus.log.socket.enable=true quarkus.log.socket.endpoint=localhost:4560 ---- +Typically, this handler is used with the `quarkus-logging-json` extension to send logs in ECS format to an Elasticsearch instance. +For an example configuration, see the xref:centralized-log-management.adoc[Centralized log management] guide. + == Add a logging filter to your log handler @@ -610,8 +612,11 @@ quarkus.console.color=false quarkus.log.category."io.quarkus".level=INFO ---- -NOTE: If you add these properties in the command line, ensure `"` is escaped. +[NOTE] +==== +If you add these properties in the command line, ensure `"` is escaped. For example, `-Dquarkus.log.category.\"io.quarkus\".level=DEBUG`. +==== [[category-example]] .File TRACE logging configuration @@ -667,7 +672,7 @@ To send logs to a centralized tool such as Graylog, Logstash, or Fluentd, see th === OpenTelemetry logging -Logging entries from all appenders can be sent using OpenTelemetry Logging. +Logging entries from all appenders can be sent by using OpenTelemetry Logging. For details, see the Quarkus xref:opentelemetry-logging.adoc[OpenTelemetry Logging] guide. @@ -677,7 +682,7 @@ Enable proper logging for `@QuarkusTest` by setting the `java.util.logging.manag The system property must be set early on to be effective, so it is recommended to configure it in the build system. -.Setting the `java.util.logging.manager` system property in the Maven Surefire plugin configuration +.Setting the `java.util.logging.manager` system property in the Maven Surefire plugin configuration: [source, xml] ---- @@ -822,7 +827,7 @@ To add data to the MDC and extract it in your log output: . Use the `MDC` class to set the data. .. Add `import org.jboss.logmanager.MDC;` -.. Set `MDC.put(...)` as shown in the example below: +.. Set `MDC.put(...)` as shown in the example below: + [source,java] .An example with JBoss Logging and `io.quarkus.logging.Log`