-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Open
Labels
feature ⚙️New feature or requestNew feature or requesthelp wanted 🆘Extra attention is neededExtra attention is needed
Milestone
Description
Summary: when Caddy is reloaded, it should re-open its log files. If the file does not exist, create one.
Use case: I would like logrotate to rotate the log files. This is the convention with logrotate services (copied from #329 (comment)). When time to rotate the configs come:
- move the log file (e.g.
mv access.log access.log.1
). - reload the process:
systemctl reload caddy
. - let the process close the log file. There is no race condition, because the process kept writing to the file with the new name until now.
- let the process re-open the log file with old (original) name. This creates a new file.
- do something with renamed log file (compress)
However, step (4) does not work: Caddy does not re-open the file.
Steps to reproduce
Caddyfile
{
http_port 8088
https_port 8084
}
http://localhost:8088 {
file_server
log {
output file access.log
}
}
- Run the server:
caddy run --config Caddyfile
- Issue a request:
curl http://localhost:8088
- Observe there is a log line in
access.log
. mv access.log access.log.1
- caddy reload --config Caddyfile --force`
- Issue a 2nd request:
curl http://localhost:8088
- Observe that the logs of the second request are in
access.log.1
, andaccess.log
was not created.
What did I expect instead?
At step (6) a new file access.log
was created and it has the mentioned log line.
Original issue: #329 (comment)
Kovah
Metadata
Metadata
Assignees
Labels
feature ⚙️New feature or requestNew feature or requesthelp wanted 🆘Extra attention is neededExtra attention is needed