Reputation: 335
I configured /etc/syslog.conf:
local0.debug /custom/path/log/app.log
so that syslog logs to a custom log file.
openlog("app", LOG_PID, LOG_LOCAL0);
Now I would also like syslog to create a different file each day, e.g.:
/custom/path/log/20210204_app.log
/custom/path/log/20210205_app.log
How can I do this?
Upvotes: 0
Views: 312
Reputation: 296
Use logrotate and configure /etc/logrotate.d/apt with your file and policies. Something like this would do the job.
/custom/path/log/app.log {
rotate 12
daily
missingok
notifempty
}
For more look here https://www.digitalocean.com/community/tutorials/how-to-manage-logfiles-with-logrotate-on-ubuntu-16-04.
Upvotes: 2