I have a large enterprise scale php app with lots of calls to error_log.
I think, at times, when exceptions are being thrown, the error log fills up the disk an causes server issues.
How can I better utilize my logging utilities in php? In particular I don’t know much about how the error_log functionalith of php is managed and used in the real world.
Are there other logging mechanisms that are more appropriate? Like an info_log or a log expiration utility that will delete/rotate log files once they get too large? Finally, can I have multiple log files?
In my opinion, error_log is good enough and provide us with sufficient functionality. Yes you can have multiple log files, you just need to manage them.:)
For example, you can use something like this:
And about auto deleting thing, I think there is no advantage of using error_log, if you really want to do auto delete. You should rather dump them somewhere, or just turn logging off/minimal using error_reporting in php.ini.
And finally, you can write your own logging class, which is really very simple and fantastic solution, because it will be very short snippet of code, and can really work according to your will. I usually do the same.
Thanks 🙂