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, eg:
/custom/path/log/20210204_app.log
/custom/path/log/20210205_app.log
How can I do this?
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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.