如何将日志内容发送到程序?

时间:2015-07-06 00:01:59

标签: apache httpd.conf error-logging

关于httpd.conf指令中的apache2(CentOS中的httpd)可以创建这样的自定义日志:

ErrorLog "|rotatelogs /var/log/httpd/error_log_%Y-%m 1G"

来源:http://httpd.apache.org/docs/2.2/programs/rotatelogs.html

所以我得出结论,可以将日志的内容发送到你看到的程序写入文件,我会创建一个程序来获取内容并将其存储在数据库中,以便进行复杂的未来咨询,我怎么能这样做?

我试过这种方式没有结果:

ErrorLog "|php /etc/httpd/log2sql.php"

在脚本中我检查:

<?php
file_put_contents('/var/log/httpd/log2sql', "\n".print_r($argv, true)."\n--------------", FILE_APPEND);
exit(0);

但它不起作用:

[root@localhost httpd]# service httpd start
                                                           [FAIL]

并记录:

Array
(
    [0] => /etc/httpd/log2sql.php
)

---------

没有参数:(

0 个答案:

没有答案
相关问题