Search code examples
spring-bootlog4jlogback

logback: FileNamePattern from application.properties


I would like to get the file name of my logback file from a property defined in the

application.properties

but I don't know if it is possible

<fileNamePattern>${user.home}/logs/>${logFileName}.%i.log.zip</fileNamePattern>

Solution

  • You can register your application.properties file in the logback.xml configuration file. logback will then recognize the properties defined in that file.

    logback.xml:

    <property resource="application.properties"/>
    

    More details: https://logback.qos.ch/manual/configuration.html#definingProps