I am deploying a Spring Boot 2.0.0-RC1 application as an init.d service, but I can't figure out how to configure the log rotation. The app logs to /var/log/appname.log, but if I configure logrotate the logging stops after a rotation, because a new file is created, and the stdout/stderr redirection defined in the embedded script does not work anymore.
If I configure the log rotation in my logging system there are two problems: I can't create the files in /var/log, and I still have the redirection defined in the embedded script.
What is the proper solution for this?
I found the solution, it's the option copytruncate in logrotate.
I'm facing the same problem in several applications and adding
copytruncate
param is the solution because your Spring Boot application doesn’t understand that the file has changed (truncated) and is acting like atail -f
command (see How does the “tail” command's “-f” parameter work? for details).Example: