I use the following logging config in my Spring Boot apps and save logs in that log file. But it creates many files (e.g. application.log.2023-02-26.0.gz
) and after a certain period of time, I need to delete old log files based on size or creation date.
logging:
pattern:
console: "%d %-5level %logger : %msg%n"
file: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
level:
org.springframework.web: error
org.hibernate: error
com.demo.app: debug
file:
name: './logs/application.log'
So, how can I remove old log files automatically?