You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After looking at the file-appender.xml from Spring Boot, I realise the property names were different and updated my logback config to use the new property names.
logback-spring.xml:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<propertyname="LOG_FILE"value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/spring.log}"/>
<includeresource="org/springframework/boot/logging/logback/defaults.xml"/>
<includeresource="org/springframework/boot/logging/logback/console-appender.xml" />
<!-- Use custom config instead of including from ecs-file-appender.xml -->
<springPropertyname="SERVICE_NAME"source="spring.application.name"/>
<appendername="ECS_JSON_FILE"class="ch.qos.logback.core.rolling.RollingFileAppender">
<filterclass="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${FILE_LOG_THRESHOLD}</level>
</filter>
<encoderclass="co.elastic.logging.logback.EcsEncoder">
<serviceName>${SERVICE_NAME:-spring-boot-application}</serviceName>
</encoder>
<file>${LOG_FILE}.json</file>
<rollingPolicyclass="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.json.%d{yyyy-MM-dd}.%i.gz}</fileNamePattern>
<cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
<maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
<maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-7}</maxHistory>
<totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap>
</rollingPolicy>
</appender>
<rootlevel="INFO">
<appender-refref="CONSOLE"/>
<appender-refref="ECS_JSON_FILE"/>
</root>
</configuration>
Using the updated config and the following application.properties:
Thanks for reporting this. Looks like indeed the property names have changed in recent spring versions. #297 adds backwards-compatible support for the new logging.logback.rollingpolicy.* options
Software Details
Issue
I was trying to modify the rolling policy of ecs-file-appender.xml via
application.properties
after including it in my logback config file.logback-spring.xml
:Following the spring boot appendix, I used the following properties in my
application.properties
file.application.properties
:However, the properties were not applied.
I tried the following properties as well and the result was the same.
application.properties
:Resolution
After looking at the file-appender.xml from Spring Boot, I realise the property names were different and updated my logback config to use the new property names.
logback-spring.xml
:Using the updated config and the following
application.properties
:The configuration was successful.
Did I make a mistake initially or are the property names in ecs-file-appender.xml not compatible with my Spring Boot version?
The text was updated successfully, but these errors were encountered: