1 | initial version |
You can use the strftime
format in the file name of the appender path, which will generate a file name with the current date and time. Here's an example YAML configuration file:
appenders:
file:
kind: file
path: "logs/app_%Y-%m-%d.log"
encoder:
pattern: "{d} [{t}] {l} - {m}{n}"
root:
level: debug
appenders:
- file
In this example, the %Y-%m-%d
format in the file name will be replaced with the current date in the format YYYY-MM-DD.
So, when you run the application on October 31, 2021, the log file generated will be app_2021-10-31.log
.
You can also include the current time in the file name by adding the %H-%M-%S
format to the file name.