Managing log files

There is a working application based on Slim 4. Logging is performed using Monolog.
I want to create a function that will check for log files for yesterday every time the app starts. If there are such files, they should be added to the zip archive, and the file itself should be deleted.
Please tell me how to add this feature to the app.
It is not clear how to design such a function, in the form of middleware or as a service.

This could be implemented as a cronjob with a Symfony console application.

Odan, thank you for your response.
Running on cron is not very convenient because when you deploy the application on a different server, you will need to create a cron task each time.
My idea is for the app to manage its logs out of the box.

You only need to create a cronjob once for each server.

If you want to archive the logfiles in a HTTP context you may slow down requests, have to handle timeouts, concurrency conflicts, locks, manual time scheduling and so on…