Under certain circumstances, the regular expression used to identify the individual fields in the log can fail to pick up the information. The problem is actually very simple - some web servers produce logs with a trailing space.
The current script has the following line:
$matched = /^(\S+)\s+(\S+)\s+(\S+)\s+\[(.*)\]
\s+"(.*)"\s+(\S+)\s+(\S+)$/x;
the problem is that the trailing '$' character indicates to only match the last field if it is right at the end of the line. The solution is to add a simple expression to match zero, or more, space characters at the end of the line:
$matched = /^(\S+)\s+(\S+)\s+(\S+)\s+\[(.*)\]
\s+"(.*)"\s+(\S+)\s+(\S+)[ ]*$/x;
Download the updated script: PC - Unix - Mac
|