vendredi 15 février 2019

How can I make Laravel log files by the hour instead of day?

I have a legacy Laravel 5.5 application with the logging set to daily, but it still generates a lot of data and I would prefer it split up by the hour, for eg.:

...
laravel-2019-02-15-00.log
laravel-2019-02-15-01.log
laravel-2019-02-15-02.log
...
laravel-2019-02-15-23.log
laravel-2019-02-16-00.log
laravel-2019-02-16-01.log
...

It seems the ability to add custom drivers was only introduced in 5.6, so I can't use one of the drivers for a better logging solution (i.e. a NoSQL database or a third party service). Without refactoring too much of this legacy application, I simply want the logs to be split by the hour. Is this possible? How can I achieve it?

I considered an OS-level solution, such as a cron calling a script every hour to rename the log, for eg.

$ mv laravel-<year>-<month>-<date>.log laravel-<year>-<month>-<date>-<hour>.log

But I would like to know if there is an easier way to do this from within Laravel.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire