I decided to write about one useful utility that I wrote in August and have been successfully using for two months.
The utility minimizes the effort of tracking PHP error logs.
Problem: The error log is a file with a bunch of lines, most of which are repeated. Therefore, no one reads them manually until there are any hard problems. It is not right. Error logs are there to be regularly reviewed, and errors are fixed.
Solution: Jenkins. What can this utility do?
- find PHP error messages in the Apache log;
- group messages about the same error;
- count the number of repetitions of each error and the time of the last detection;
- generate an HTML report on a bundle of logs;
- send the result of the execution to the mail;
- rotate logs by yourself.
An example of the simplest use is to hang it on crowns:
05 00 * * * www ~ / scripts / jenkins.php -mme@coldflame.in.ua -r / var / log / apache2 / *. Error.log
The utility will run at five minutes after midnight, collect all the logs for the specified mask (on the basis that there is a separate log file for each site), and send the result to the specified e-mail, and then rotate the logs. Very comfortably. A piece of the letter with the result:
Jenkins report for somesite.com-error.log
')
Total lines in log: 1750525
Lines recognized as PHP errors: 1748006
Unique PHP error messages: 40
Error messages
Notice: blah-blah-blah [/home/user/file.php.7380] (1234 times, last seen on 08/24/08 00:36)
Notice: foobar [/home/user/other-file.php:123] (14 times, last seen on 08/24/08 12:34)
... etc
Another use is for analyzing the accumulated gigabyte log, with which you seemingly can't do anything. But as a rule, there are more errors on the visited sites of repetitions of errors than the errors themselves - therefore, if we group them, a completely correctable report is obtained.
Download . Suggestions and suggestions can send me any convenient way.