_Here, the first property specifies the original log file name, and the second one specifies the pattern for the files which will be rolled out the next days (daily rolling). In the pattern, I append date format %d{yyyy-MM-dd} and the ordinal number of the log file (%i) to the file name (MyApp-)_
So when our Spring Boot application starts, Logback will clean the old log files based on the values of total size and max history. This property is set to false by default.
Setup logging (apps 1 and 2 APIs)
Related issues: #1, #4
Dev environment
Prod environment
Output: console disabled, log to file
Root logger level: INFO
[ ] logging.level.root=INFO
Basically, you just need to specify the following two lines in the application.properties file to enable daily rolling files logging:
First, you have to specify the file name
[ ] logging.file.name=${supportrequest.logs.file.location}/${supportrequest.logs.file.name}.current.log
Then: you must have a name pattern
_Here, the first property specifies the original log file name, and the second one specifies the pattern for the files which will be rolled out the next days (daily rolling). In the pattern, I append date format %d{yyyy-MM-dd} and the ordinal number of the log file (%i) to the file name (MyApp-)_
[ ] logging.logback.rollingpolicy.file-name-pattern=${supportrequest.logs.file.location}/${supportrequest.logs.file.name}.%d{yyyy-MM-dd}.%i.log.gz
Rolling policy: A rolling policy must be set based on
max file size
andtotal size cap
You can also specify a threshold for log file size using the following property
You can control the total size of all log files under a specified number, by using the following property:
Optional :
logging.file.clean-history-on-start=true
So when our Spring Boot application starts, Logback will clean the old log files based on the values of total size and max history. This property is set to false by default.
Source : https://www.codejava.net/frameworks/spring-boot/logback-rolling-files-example