Closed dmhai closed 2 years ago
I presume you mean the log file enabled by the --log
option to rest-server
, correct? If yes, there's no feature in rest-server currently where it writes the log to a file that changes with the current date.
A workaround is that you run rest-server with e.g. --log
date +%Y%m%d.log
, and simply restart it (with the same command) at 00:00 every night. Then you will get a new log file for every day. Make sure to rotate those files so they don't fill up your disk space in the end.
logrotate is good for that, something similar to
/path/to/rest-server.log {
daily
dateext
postrotate
/bin/systemctl reload rest-server.service
endscript
}
dateext is appending the current date to the rotated log file
How can I format the log filename dynamically (e.g. yyyyMMdd.log), I need to read the log by date.