Use SizeAndTimeBasedRollingPolicy file appender
Update the logback file appender to use `SizeAndTimeBasedRollingPolicy`
rather than `FixedWindowRollingPolicy`.
Add two new properties to improve log file configuration capabilities:
- `logging.file.max-history` to limit the number of archive log files
to keep.
- `logging.file.max-size` to limit the log file size.
See gh-6352
This commit is contained in:
committed by
Phillip Webb
parent
f440fc6d25
commit
991468b0ef
@@ -41,6 +41,8 @@ content into your application; rather pick only the properties that you need.
|
||||
logging.config= # Location of the logging configuration file. For instance `classpath:logback.xml` for Logback
|
||||
logging.exception-conversion-word=%wEx # Conversion word used when logging exceptions.
|
||||
logging.file= # Log file name. For instance `myapp.log`
|
||||
logging.file.max-history= # Maximum of archive log files to keep. Only supported with the default logback setup.
|
||||
logging.file.max-size= # Maximum log file size. Only supported with the default logback setup.
|
||||
logging.level.*= # Log levels severity mapping. For instance `logging.level.org.springframework=DEBUG`
|
||||
logging.path= # Location of the log file. For instance `/var/log`
|
||||
logging.pattern.console= # Appender pattern for output to the console. Only supported with the default logback setup.
|
||||
|
||||
@@ -1533,7 +1533,9 @@ relative to the current directory.
|
||||
|===
|
||||
|
||||
Log files rotate when they reach 10 MB and, as with console output, `ERROR`-level,
|
||||
`WARN`-level, and `INFO`-level messages are logged by default.
|
||||
`WARN`-level, and `INFO`-level messages are logged by default. Size limits can be changed
|
||||
using the `logging.file.max-size` property. Previously rotated files are archived
|
||||
indefinitely unless the `logging.file.max-history` property has been set.
|
||||
|
||||
NOTE: The logging system is initialized early in the application lifecycle. Consequently,
|
||||
logging properties are not found in property files loaded through `@PropertySource`
|
||||
@@ -1620,6 +1622,14 @@ To help with the customization, some other properties are transferred from the S
|
||||
|`LOG_FILE`
|
||||
|If defined, it is used in the default log configuration.
|
||||
|
||||
|`logging.file.max-size`
|
||||
|`LOG_FILE_MAX_SIZE`
|
||||
|Maximum log file size (if LOG_FILE enabled). (Only supported with the default logback setup.)
|
||||
|
||||
|`logging.file.max-history`
|
||||
|`LOG_FILE_MAX_HISTORY`
|
||||
|Maximum number of archive log files to keep (if LOG_FILE enabled). (Only supported with the default logback setup.)
|
||||
|
||||
|`logging.path`
|
||||
|`LOG_PATH`
|
||||
|If defined, it is used in the default log configuration.
|
||||
|
||||
Reference in New Issue
Block a user