Tech Blog :: Parse Drupal watchdog logs in syslog (using node.js script)
Parse Drupal watchdog logs in syslog (using node.js script)
Drupal has the option of outputting its watchdog logs to syslog, the file-based core Unix logging mechanism. The log in most cases lives at /var/log/messages, and Drupal's logs get mixed in with all the others, so you need to
cat /var/log/messages | grep drupal to filter.
I put the code in a Gist, node.js script to parse Drupal logs in linux syslog (and find distinct 404'd URLs). The last few lines of URL filtering can be changed to any other specific use case you might have for reading the logs out of syslog. (This could also be used for reading non-Drupal syslogs, but the mapping applies keys like "URL" which wouldn't apply then.)
Note the comment at the top: to run it you'll need node.js and 2 NPM modules as dependencies. Then take your filtered log (using the
greg method above) and pass it as a parameter, and read the output on screen or output with
> to another file.