Log watcher: Watch a log file and e-mail newly added lines

Recommend this page to a friend!
  Info   Screenshots   View files (6)   Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
68%Total: 4,544 All time: 615 This week: 298
Version License Categories
logwatcher 1.0.0BSD LicenseLogging, Security
Description Author

This class is meant to poll log files and take any newly added lines and send them to a given watcher e-mail address.

Although this class can be used to poll any type of log files, it was developed with the intention to overcome a limitation of the PHP error trapping system that is not able to capture certain types of errors like script parsing errors or file upload failures. Despite of this, these errors are sent to a log file if error logging is enabled in the PHP configuration.

The goal of this class is to capture the error messages sent to log files and send them by e-mail to a person responsible for a site, so any necessary action may be taken with minimal delay.

To use this class to watch the PHP error log, take the example script and adjust any values to match your PHP configuration.

For security reasons, in a production environment, you are strongly encouraged disable displaying PHP errors on Web pages and enable logging errors to a log file. A sample php.ini configuration file is provided to indicate which options should be set in a production environment.

Picture of Manuel Lemos
  Performance   Level  
Name: Manuel Lemos is available for providing paid consulting. Contact Manuel Lemos .
Classes: 41 packages by
Country: Portugal Portugal
Age: 51
All time rank: 1
Week rank: 4 1 in Portugal Portugal

Screenshots  
  • logwatcher.gif
  Files  
File Role Description
error_handler.php Aux. Example of an error handler function that logs the error message, the file name, line number, function name, class name, including backtrace of all the function calls that lead to the line where the error occurred.
log_watcher_class.html Doc. Class documentation extracted from inline meta-document comments
log_watcher_class.php Class Log watcher class
php.ini Data Sample PHP configuration with options set for maximum logging security in a production environment
php_error_log.crontab Data Example of crontab line to execute the example log script to watch the PHP error log
test_log_watcher.php Example Example of how to setup the class to watch a given log file, e-mail the newly added lines, if any, and exit

logwatcher-2006-01-11.zip 20KB
logwatcher-2006-01-11.tar.gz 19KB
Install with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
MIME E-mail message sending .zip .tar.gz When the mail delivery method is meant to replaced by the urgent mail function Optional
 Version Control Unique User Downloads Download Rankings  
 0%
Total:4,544
This week:0
All time:615
This week:298
 User Ratings  
 
 All time
Utility:89%
Consistency:82%
Documentation:78%
Examples:82%
Tests:-
Videos:-
Overall:68%
Rank:505
  

For more information send a message to info at phpclasses dot org.