'Systemd log rotation?
I have a Java application currently running in a container on AWS ECS. It prints logs to stdout and the container runtime environment handles the transfer of those logs to AWS CloudWatch Logs. Now I need to make it run directly on a server and prevent it from filling the disk.
The application code currently only outputs logs to stdout, so is there a way to have systemd start it and have it funnel logs to a file on the file system while handling log rotation for you?
I know I can do something like StandardOutput=/var/log/foo.log in the service file, but in this case if I rotate the log file, the application still holds a file descriptor to the file, so it will just keep writing the data to the renamed file instead of starting to write to a new one. I could always restart the service, but since the server holds a few hundred thousand open network sockets, doing so would cut all the connections.
The application uses slf4j for logging, so another option would be to configure some log rotating logging backend for it, which I know exists, but this requires changing the application.
This is a problem that syslog used to solve...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
