Logrotate for logs to prevent nightmare such as 4G error.log
- Member | 51
As a webhoster I can very often see developers write some piece of code that generates a lot of exceptions/errors/warnings/logs. The problem is they don't manage them properly and they just leave them on the server.
It would be nice to have some kind of logrotate at lease for large files such as error.log, exception.log.
- The solution might be simple – let's talk about error.log
- set limit of file size (10M as default?)
- if the file size reaches the limit, rotate error.log to error.log.1 (error.log.1 → error.log.2 …)
- delete error.log.7
Last edited by skrivy (2015-12-22 09:36)
- Member | 114
Are you looking for something like this?
Rotating log is something which should be done periodically. By logrotate
daemon or cron,
not by PHP framework.
- Filip Procházka
- Moderator | 4668
I suggest using the Monolog, for example through kdyby/monolog. That way you can easily add logrotate handler.
But generally, imho better is to use some log collector, monolog also implements handlers for quite a lot of them.