PHP-on-Apache Log Analyzer

    I decided to write about one useful utility that I wrote in August and have been successfully using for two months now.
    The utility minimizes the effort to track PHP error logs.

    Problem: The error log is a file with a bunch of lines from which most are repeated. Therefore, nobody reads them manually until some tough problems arise. It is not right. Error logs exist for them to be regularly reviewed, and errors to be eliminated.

    Solution: Jenkins. What does 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 pack of logs;
    • send the result to e-mail;
    • rotate the logs yourself.

    An example of the simplest use is to hang on crowns:
    05 00 * * * www ~ / scripts / jenkins.php -r / var / log / apache2 / *. Error.log

    The utility will start five minutes after midnight, collect all the logs by the specified mask (assuming that each site has a separate log file), 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

    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.phphaps80] (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 case is to analyze the accumulated gigabyte log, with which it would seem that you will not do anything. But as a rule, there are more repetitions of errors on the visited sites than there are errors themselves - therefore if you group them together, you get a completely correctable report.

    Download . You can send me suggestions and wishes in any convenient way.

    Also popular now: