I had this same need and it turned out to be quite easy with the help of spring boot"ifulness" and conditional support available for logback. The following is a template that I came up with that could be for any app as it creates the logfile using spring.applcation.name if available, which you can define in bootstrap.properties:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project>
<configuration>
<if condition='isDefined("logging.path")'>
<then>
<!-- get application name from external properties file -->
<property resource="bootstrap.properties" />
<!-- set local properties here for better visibility -->
<!-- TODO: make these profile conditional based on profiles -->
<property name="logging.maxfilesize" value="1GB" />
<property name="logging.maxdays" value="180" />
<!-- Assume file strategy for appender if logging path given -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- Use application.log if s.a.n not defined in bootstrap.properties -->
<file>${logging.path}/${spring.application.name:-application}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>${logging.path}/${spring.application.name:-application}.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches maxFileSize -->
<maxFileSize>${logging.maxfilesize}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- keep max days' worth of history -->
<maxHistory>${logging.maxdays}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root>
<appender-ref ref="FILE" />
</root>
</then>
<else>
<!-- The logging path not specified so assume console output -->
<!-- Note: In this case we don't care about the full date just the hour minutes seconds -->
<appender name="CON" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} %-5level %logger{35} - %msg %n</pattern>
</encoder>
</appender>
<root>
<appender-ref ref="CON" />
</root>
</else>
</if>
<!-- in-house loggers -->
<!-- 3rdparty Loggers -->
<logger name="org.springframework">
<level value="WARN" />
</logger>
<!-- default root level for everything else -->
<root>
<level value="INFO" />
</root>
</configuration>
If spring boot app with starter parent, you only need add the following to your pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<!-- Needed for conditional logback.xml statement support - very cool stuff -->
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
</dependency>