I am using Spring, Logback and maven. I would like to put all my settings to properties which will be outside jar that I build with maven. So I moved all setting from Logback.xml. Now it looks like:
<configuration>
<property resource="application.properties" />
<timestamp key="byDate" datePattern="yyyyMMdd"/>
<!-- Send messages to System.out - CONSOLE -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
</encoder>
<withJansi>true</withJansi>
</appender>
<!-- Send messages to a file -->
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${logging.path}/${spring.application.name}-${byDate}.log</file>
<append>true</append>
<!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
</encoder>
</appender>
<root level="${logging.level}">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
My application.properties file is:
#Spring settings
spring.application.name=MyApp
server.port=8087
# Logging settings
logging.level=INFO
logging.path=/Users/...some path.../logs/
I put this to bean:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="file:application.properties"/>
</bean>
And excluded application.properties from maven build with plugin:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<copy todir="target" overwrite="true">
<fileset dir="src/main/resources/">
<include name="*.properties"/>
</fileset>
</copy>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
But it isn't work for me. Log file name loose datePattern and nothing I changed in property file is not changing. What is wrong? Please.
UPDATE: There is no errors. Everything works fine. And I can change all settings with run in IDE. So I believe that I do something wrong with maven build.