I have a spring boot application and I would like to have logback create a log file, with the current date (including minutes hours and seconds). So there will be a file for each time the application is run.
To do this I did this:
<springProperty name="log_path_folder" source="log.path.folder"/>
<property name="application_filename" value="application"/>
<timestamp key="currentDate" datePattern="yyyy-MM-dd'_'HH.mm.ss"/>
<appender name="APPLICATION_FILE" class="ch.qos.logback.core.FileAppender">
<file>${log_path_folder}/${application_filename}-${currentDate}.log</file>
<encoder>
<pattern>%d [%thread] %-5level [%marker] %msg%n</pattern>
</encoder>
</appender>
<root level="info" additivity="false">
<appender-ref ref="APPLICATION_FILE"/>
</root>
This works correctly. The problem is that I don't know how to add checks on a maximum number of files or on the maximum size of the folder with all the logs. I know it is possible to use the RollingFileAppender. The problem is that if I put the seconds in the filename, it creates a file for every minute. So I won't have all the logs of a run in one file.