Skip to content

Commit 55e4e9f

Browse files
committed
Document caveat of combining "Structured Logging" and "Custom Log Configuration"
1 parent f3a161a commit 55e4e9f

File tree

1 file changed

+29
-0
lines changed
  • spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/features

1 file changed

+29
-0
lines changed

spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/features/logging.adoc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,35 @@ Spring Boot supports structured logging and has support for the following JSON f
450450

451451
To enable structured logging, set the property configprop:logging.structured.format.console[] (for console output) or configprop:logging.structured.format.file[] (for file output) to the id of the format you want to use.
452452

453+
If you are using xref:#features.logging.custom-log-configuration[Custom Log Configuration], update your configuration to respect `CONSOLE_LOG_STRUCTURED_FORMAT` and `FILE_LOG_STRUCTURED_FORMAT` system properties.
454+
Take `CONSOLE_LOG_STRUCTURED_FORMAT` for example:
455+
[tabs]
456+
======
457+
Logback::
458+
+
459+
[source,xml]
460+
----
461+
<!-- replace your encoder with StructuredLogEncoder -->
462+
<encoder class="org.springframework.boot.logging.logback.StructuredLogEncoder">
463+
<format>${CONSOLE_LOG_STRUCTURED_FORMAT}</format>
464+
<charset>${CONSOLE_LOG_CHARSET}</charset>
465+
</encoder>
466+
----
467+
Log4j2::
468+
+
469+
[source,xml]
470+
----
471+
<!-- wrap your PatternLayout with <Select> and <DefaultArbiter> -->
472+
<Select>
473+
<SystemPropertyArbiter propertyName="CONSOLE_LOG_STRUCTURED_FORMAT">
474+
<StructuredLogLayout format="${sys:CONSOLE_LOG_STRUCTURED_FORMAT}" charset="${sys:CONSOLE_LOG_CHARSET}"/>
475+
</SystemPropertyArbiter>
476+
<DefaultArbiter>
477+
<!-- place your pattern layout here -->
478+
</DefaultArbiter>
479+
</Select>
480+
----
481+
======
453482

454483

455484
[[features.logging.structured.ecs]]

0 commit comments

Comments
 (0)