I have a small project with Spring Boot and maven, and now I'm trying to configure logback to write to a file. I want it to be written to the file specified by ${project.build.directory}/${log.folder}/logfile.log , so the subfolder of the assembly directory, which is ${log.folder} , is the property that I specify in file application.properties , is placed in my /resources folder.
This is my logback.xml
<?xml version="1.0" encoding="UTF-8"?> <configuration> <include resource="org/springframework/boot/logging/logback/base.xml"/> <logger name="org.springframework.boot" level="INFO"/> <logger name="org.springframework.security" level="ERROR"/> <logger name="org.glassfish.jersey" level="DEBUG"/> <property resource="application.properties"/> <appender name="DUMMY_APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${project.build.directory}/${log.folder}/logfile.log</file> <encoder> <pattern>%d{"yyyy-MM-dd HH:mm:ss,SSS zzz"}, [%thread] %-5level %logger{5} - %msg%n </pattern> </encoder> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${log.folder}/spring.log.%d</fileNamePattern> </rollingPolicy> </appender> <logger name="xxxxxx" level="INFO" additivity="false"> <appender-ref ref="DUMMY_APPENDER"/> </logger> <root level="INFO"> <appender-ref ref="DUMMY_APPENDER"/> </root> </configuration>
It writes logs, but my problem is that when the application starts, it creates the project.build.directory_IS_UNDEFINED folder and then puts my log file under it. He says in the documentation that
As a build tool, logback is based on Maven, the widely used open-source build tool.
And when I start typing $ {pro ... in logback.xml, then my IDE displays the set of available implicit maven properties .
Therefore, it should work, but it is not. Any idea why?
source share