This question already has an answer here:
Is there a way to search the error log for only unique errors. Reason being I have a lot of duplicate errors and don't want to miss the rare ones.
How would I go about writing a custom script which parses the error log, and filters out all of the duplicates excluding the datetime.
</div>
Set ignore-repeated-errors
= On
in php.ini or add ini_set('ignore-repeated-errors', 1);
to your php scripts
This will stop php from logging an error more than once i.e. error messages caused by same line in same script.
To analyze /var/log/apache2/error.log
use
sed 's^\[.*\]^^g' /var/log/apache2/error.log | sort | uniq -c
This will
cut the date at the beginning of each line like:
[28-Aug-2012 11:20:24 UTC] PHP Notice: Undefined index: test in /var/www/... on line ...
sort them according to numerical value
finds and counts unique lines
source: strictcoder.blogspot.de