写入到Apache的access_log与PHP文件 [英] Writing to Apache access_log file with php
问题描述
我需要写的统计数据,以实时Apache的访问日志文件(我有另一个进程在定期报告给另一个进程的访问日志文件计数特定行)。
I need to write statistical data to the live Apache access_log file (I have another process counting specific lines in the access_log file that reports periodically back to another process).
目前我只是做在PHP以下迫使一个进入访问日志文件:
Currently I am simply forcing an entry into the access_log file by doing the following in php:
file("http://127.0.0.1/logme.php?stuff_that_I_can_watch_here");
logme.php不执行任何操作,并返回空用200的成功。
logme.php does nothing and returns empty with a 200 success.
上述技术的问题是,对每个请求Apache服务器,另一个是催生写入日志 - 因此需要加倍的Apache服务器
The problem with the above technique is that for every request to the Apache server, another is spawned to write to the log - hence doubling required apache servers.
在服务器堆积起来,到Apache服务器的简单,通常快速的本地通话接管5秒。
When the servers pile up, the simple and usually fast local call to the Apache server takes over 5 seconds.
我可以写入访问日志文件的情况下直接导致的问题,或者甚至是有办法使用类似PHP到系统日志写入apache_log文件()或error_log中()?
Can I write to the access_log file directly without causing problems, or maybe even is there a way to write to the apache_log file using php similar to syslog() or error_log()?
推荐答案
您可以使用 apache_note
( http://php.net/apache_note ),以你的价值观写一张纸条,然后使用的CustomLog
与的LogFormat
(%{NOTE_NAME} n的
)(的 http://httpd.apache.org/docs/2.2/mod/mod_log_config.html )登录新密钥。然后,您的方案,其中分析访问日志可以读出新的记录参数以及
You can use apache_note
(http://php.net/apache_note) to write your values to a note and then use CustomLog
with LogFormat
(%{NOTE_NAME}n
) (http://httpd.apache.org/docs/2.2/mod/mod_log_config.html) to log the new keys. Your programs which parse the access log can then read the new logging parameters as well.
这篇关于写入到Apache的access_log与PHP文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!