forked from spring-projects/spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logback XML configuration for structured logging
- Loading branch information
1 parent
00d0567
commit 087ddea
Showing
4 changed files
with
71 additions
and
14 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...esources/org/springframework/boot/logging/logback/console-structured-logging-appender.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
Console appender with structured logging logback configuration provided for import, | ||
equivalent to the programmatic initialization performed by Boot | ||
--> | ||
|
||
<included> | ||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | ||
<level>${CONSOLE_LOG_THRESHOLD}</level> | ||
</filter> | ||
<encoder class="org.springframework.boot.logging.logback.StructuredLoggingEncoder"> | ||
<format>${CONSOLE_LOG_STRUCTURED}</format> | ||
<charset>${CONSOLE_LOG_CHARSET}</charset> | ||
<pid>${PID:--1}</pid> | ||
<serviceName>${APPLICATION_NAME:-}</serviceName> | ||
</encoder> | ||
</appender> | ||
</included> |
28 changes: 28 additions & 0 deletions
28
...n/resources/org/springframework/boot/logging/logback/file-structured-logging-appender.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
File appender with structured logging logback configuration provided for import, | ||
equivalent to the programmatic initialization performed by Boot | ||
--> | ||
|
||
<included> | ||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | ||
<level>${FILE_LOG_THRESHOLD}</level> | ||
</filter> | ||
<encoder class="org.springframework.boot.logging.logback.StructuredLoggingEncoder"> | ||
<format>${FILE_LOG_STRUCTURED}</format> | ||
<charset>${FILE_LOG_CHARSET}</charset> | ||
<pid>${PID:--1}</pid> | ||
<serviceName>${APPLICATION_NAME:-}</serviceName> | ||
</encoder> | ||
<file>${LOG_FILE}</file> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> | ||
<fileNamePattern>${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz}</fileNamePattern> | ||
<cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart> | ||
<maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize> | ||
<totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap> | ||
<maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-7}</maxHistory> | ||
</rollingPolicy> | ||
</appender> | ||
</included> |
16 changes: 16 additions & 0 deletions
16
...-boot-smoke-test-simple/src/main/resources/custom-structured-logging-console-appender.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<included> | ||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | ||
<level>${CONSOLE_LOG_THRESHOLD}</level> | ||
</filter> | ||
<encoder class="org.springframework.boot.logging.logback.StructuredLoggingEncoder"> | ||
<format>${CONSOLE_LOG_STRUCTURED}</format> | ||
<charset>${CONSOLE_LOG_CHARSET}</charset> | ||
<pid>${PID:--1}</pid> | ||
<serviceName>${APPLICATION_NAME:-}</serviceName> | ||
<serviceVersion>1.0.0-SNAPSHOT</serviceVersion> | ||
<serviceNodeName>node-1</serviceNodeName> | ||
<serviceEnvironment>production</serviceEnvironment> | ||
</encoder> | ||
</appender> | ||
</included> |
21 changes: 7 additions & 14 deletions
21
...-smoke-tests/spring-boot-smoke-test-simple/src/main/resources/logback-spring.xml.disabled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/> | ||
<appender name="JSON_CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | ||
<level>${CONSOLE_LOG_THRESHOLD}</level> | ||
</filter> | ||
<encoder class="org.springframework.boot.logging.logback.StructuredLoggingEncoder"> | ||
<format>ECS</format> | ||
<pid>${PID}</pid> | ||
<serviceName>${APPLICATION_NAME}</serviceName> | ||
<serviceNodeName>node-1</serviceNodeName> | ||
<serviceEnvironment>production</serviceEnvironment> | ||
</encoder> | ||
</appender> | ||
|
||
<!-- <include resource="org/springframework/boot/logging/logback/console-appender.xml" />--> | ||
<!-- <include resource="org/springframework/boot/logging/logback/file-appender.xml" />--> | ||
<!-- <include resource="org/springframework/boot/logging/logback/console-structured-logging-appender.xml" />--> | ||
<include resource="org/springframework/boot/logging/logback/file-structured-logging-appender.xml" /> | ||
<include resource="custom-structured-logging-console-appender.xml" /> | ||
<root level="INFO"> | ||
<appender-ref ref="JSON_CONSOLE" /> | ||
<appender-ref ref="CONSOLE" /> | ||
<appender-ref ref="FILE" /> | ||
</root> | ||
</configuration> |