I want to delete log files automatically in my Spring Boot apps and use the following settings:
logging:
file:
name: './logs/application.log'
max-size: 10KB # for test purpose keep small
max-history: 5
Here is the documentation page: https://docs.spring.io/spring-boot/docs/2.1.13.RELEASE/reference/html/boot-features-logging.html
However, neither max-size
nor max-history
is working and new log files are created more than 5.
I am not sure if I have to set logback
config, but if I have to, is the following approach suitable for deleting log files automatically?
https://www.codejava.net/frameworks/spring-boot/logback-rolling-files-example
max-history
determines not the amount of files but the number of days to keep the logs, so in your case everything older than 5 days will be deleted.max-history
and wait the log files to be deleted by older than x days ?logging.file.clean-history-on-start=true