Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying the QE feedback to the Logging guide #40074

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions docs/src/main/asciidoc/logging.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
[source,java]
----
package com.example;

import org.jboss.logging.Logger;

public class MyService {
Expand Down Expand Up @@ -129,6 +130,8 @@
.An example of two different types of logger injection:
[source, java]
----
package com.example;

import org.jboss.logging.Logger;

@ApplicationScoped
Expand Down Expand Up @@ -203,9 +206,8 @@

== Configure the log level, category, and format

JBoss Logging is built into Quarkus and provides link:https://quarkus.io/developer-joy/[unified configuration] for all <<logging-apis,supported logging APIs>>.

Configure the runtime logging in the `application.properties` file.
JBoss Logging, integrated into Quarkus, offers a unified configuration for all <<logging-apis,supported logging APIs>> through a single configuration file that sets up all available extensions.
To adjust runtime logging, modify the `application.properties` file.

.An example of how you can set the default log level to `INFO` logging and include Hibernate `DEBUG` logs:
[source, properties]
Expand Down Expand Up @@ -347,9 +349,9 @@
|%t|Thread name|Render the thread name.
|%t{id}|Thread ID|Render the thread ID.
|%z{<zone name>}|Time zone|Set the time zone of the output to `<zone name>`.
|%X{<MDC property name>}|Mapped Diagnostic Context Value|Renders the value from Mapped Diagnostic Context
|%X|Mapped Diagnostic Context Values|Renders all the values from Mapped Diagnostic Context in format {property.key=property.value}
|%x|Nested Diagnostics context values|Renders all the values from Nested Diagnostics Context in format {value1.value2}
|%X{<MDC property name>}|Mapped Diagnostic Context Value|Renders the value from Mapped Diagnostic Context.
|%X|Mapped Diagnostic Context Values|Renders all the values from Mapped Diagnostic Context in format `{property.key=property.value}`.
|%x|Nested Diagnostics context values|Renders all the values from Nested Diagnostics Context in format `{value1.value2}`.
|===


Expand All @@ -364,8 +366,8 @@

The `quarkus-logging-json` extension may be employed to add support for the JSON logging format and its related configuration.

Add this extension to your build file as the following snippet illustrates:

. Add this extension to your build file as the following snippet illustrates:

Check warning on line 369 in docs/src/main/asciidoc/logging.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using 'because' or 'while' rather than 'as'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using 'because' or 'while' rather than 'as'.", "location": {"path": "docs/src/main/asciidoc/logging.adoc", "range": {"start": {"line": 369, "column": 41}}}, "severity": "INFO"}
+
[source,xml,role="primary asciidoc-tabs-target-sync-cli asciidoc-tabs-target-sync-maven"]
.pom.xml
----
Expand All @@ -374,20 +376,21 @@
<artifactId>quarkus-logging-json</artifactId>
</dependency>
----

+
[source,gradle,role="secondary asciidoc-tabs-target-sync-gradle"]
.build.gradle
----
implementation("io.quarkus:quarkus-logging-json")
----

+
By default, the presence of this extension replaces the output format configuration from the console configuration, and the format string and the color settings (if any) are ignored.
The other console configuration items, including those controlling asynchronous logging and the log level, will continue to be applied.

+
For some, it will make sense to use humanly readable (unstructured) logging in dev mode and JSON logging (structured) in production mode.
This can be achieved using different profiles, as shown in the following configuration.

Check warning on line 390 in docs/src/main/asciidoc/logging.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'.", "location": {"path": "docs/src/main/asciidoc/logging.adoc", "range": {"start": {"line": 390, "column": 10}}}, "severity": "INFO"}

.Disable JSON logging in application.properties for dev and test mode
+
MichalMaler marked this conversation as resolved.
Show resolved Hide resolved
. Disable JSON logging in application.properties for dev and test mode:
+
[source, properties]
----
%dev.quarkus.log.console.json=false
Expand Down Expand Up @@ -514,6 +517,8 @@
.An example of writing a filter:
[source,java]
----
package com.example;

import io.quarkus.logging.LoggingFilter;
import java.util.logging.Filter;
import java.util.logging.LogRecord;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class AdditionalFieldConfig {

/**
* Additional field type specification.
* Supported types: string, int, long
* Supported types: {@code string}, {@code int}, and {@code long}.
* String is the default if not specified.
*/
@ConfigItem(defaultValue = "string")
Expand Down
Loading