Advice on repeated errors logged by Phalcon\Logger\Adapter\File

Hi I'm facing a trouble that my phalcon project error logs eating my webserver disks. the log size grows 7GB in 3days. The source of the problem is that I'm currently using error_reporting(E_ALL) and the the same E_NOTICEs get logged several hundred times. The question is how to make Phalcon\Logger\Adapter\File only logged the error only if there is no exact same error in the previous last 5 lines of log?

Hi @jeffreycahyono

Actually when you log something it is just appended to the end of the log file. Let's imagine you are trying to log something according to the already present log. Then eveyrtimes that a log occurs, the logger will check old entries with some conditions, and it may overload some process.

I think you will have to digg into some external proccess that (lets say every 15 minutes) will check you log file and delete the duplications. Maybe that logrotate can do this, but not sure.

Also, there is way to avoid some error repporting by using an @ before your call (but this is a really bad practise)

You could set up a the log rotation demon to rotate the log file after so many hours or GB.

The better solution (and I would imagine the point of the log file) would be to actually stop those errors from happening by fixing your code.

I agree with quasipickle! The best practice is to prevent the error from occurring in the first place. Then setup a log rotation to manage to logs an keep them from exploding your HDD. Also you can configure the error_reporting not to log all things. example: E_ALL & ~E_NOTICE

OK, I will examine logrotate command and of course, learn to have a good coding practice :) Thanks all,

@jeffreycahyono

I just have discovered the following onfig in the php.ini

ignore_repeated_errors = Off

But still it doesnt prevent you to code without errors ;)