How can I craete a RollingFileAppender
in Logback that accepts the prudent flag and also allows me to specifity the location of the log files?
I tried the following but as I understand from the documentation logback doesn't support the file property. Is there another way to set the log file location?
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${MY_LOG_LOCATION_PROP}/logs/mylogfile.log</file>
<prudent>true</prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>mylogfile-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
If the
file
property is missing, the currently active log file will be inferred from the value offileNamePattern
. Thus, thefile
property is not mandatory. Just as importantly, in prudent mode it must be left blank.Here is the relevant quote from the documentation on fileNamePattern:
You can include the path in the fileNamePattern: