I have Spring Boot application and set in application.properties next variables:
logging.config=file:./xxx_logback.xml
appName=myapp
appVersion=1.0
Application create correctly logfile after start. But when I change logging level, logback create new logfile with name "appName_IS_UNDEFINED-appVersion_IS_UNDEFINED". I use next logback config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="10 seconds">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
<!-- To enable JMX Management -->
<jmxConfigurator/>
<springProperty scope="context" name="appName" source="appName"/>
<springProperty scope="context" name="appVersion" source="appVersion"/>
<appender name="FILE-APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/${appName}-${appVersion}.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>logs/${appName}-${appVersion}-%d{yyyy-MM-dd}-%i.log.zip</fileNamePattern>
<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>utf-8</charset>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
</encoder>
</appender>
<root level="warn">
<appender-ref ref="FILE-APPENDER"/>
</root>
<logger name="xxx.xxx" level="warn"/>
</configuration>
Can't understand how to fix it.
Most likely the reason is this:
The extensions cannot be used with Logback’s configuration scanning. If you attempt to do so, making changes to the configuration file results in an error.