I have to write record data towards the live Apache access_log file (I've another process counting specific lines within the access_log file that reviews periodically to another process).
Presently I'm simply forcing an entry in to the access_log file by doing the next in php:
logme.php does nothing and returns empty having a 200 success.
The issue using the above way is that for each request towards the Apache server, these guys created to create towards the log - hence doubling needed apache servers.
Once the servers stack up, the easy in most cases fast local call towards the Apache server gets control 5 seconds.
Can One email the access_log file directly without leading to problems, and maybe even it is possible to method to email the apache_log file using php much like syslog() or error_log()?
<?php $h = fopen('/path/to/access_log', 'a'); fwrite($h, 'Message'); fclose($h); ?>
Others have previously said concerning the design. The Apache access_log is perfect for Apache to log accesses, period.
I uses in regards to a dozen custom log files in a single application for the different monitoring, performance analysis and forensic reasons. One log file per purpose makes log analysis simpler.
could it be ok to create to gain access to_log directly
You are able to write straight to access_log, however is not OK to get this done.
A running apache can spawn multiple processes,
and lock apply for write using reduced process like PHP is simply further delay logging speed.
or perhaps is there a good way to offer the same effect using php
Don't use PHP, add an additional custom log if your request full-fill your requirement.
This really is more most convenient way which custom log should consists of lesser line, like static file access isn't drenched. Which directly improve parsing from the log later.