This app works fine in IntelliJ and creates the log files as per configurations, however when launched the app from command line its not using logback-spring.xml file and instead goes on to create *tmp/spring.log file which seems to coming from spring *logback/base.xml. I have spent couple of days to troubleshoot this issue but nothing seems to work so far and other questions do not address the underlying issue, your help is appreciated.
I am launching the app as -
java -jar abc.jar -Dspring.profiles.active=test
I can see that logback-spring.xml is present inside abc.jar as
BOOT-INF/classes/ logback-spring.xml
Here you can find how to configure logback
with spring-boot
howto.logging.logback
With src/main/resources/logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<!-- include spring boot file-appender -->
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" /> <!-- add file-appender -->
</root>
<logger name="com.example" level="DEBUG"/>
</configuration>
And providing a logging file-name in src/main/resources/application.properties
logging.file.name=application.log
You should see a file application.log in the same directory as you launched your application with
java -jar your-app.jar --spring.profiles.active=test