我有一个网站运行使用Apache 2.2.22,PHP 5.3.10和cURL 7.2.00。 下面是apacheconfiguration的相关部分,您会注意到错误发送到www.example.com_error.log 。
<VirtualHost *:443> ServerName example.com ServerAlias www.example.com # *snip* ErrorLog ${APACHE_LOG_DIR}/example.com_error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined </VirtualHost>
但是,当我从PHP内使用cURL,并使用curl_setopt($connection, CURLOPT_VERBOSE, true);详细日志loggingcurl_setopt($connection, CURLOPT_VERBOSE, true); cURL的输出进入Apache的error.log而不是我上面定义的自定义日志文件。 为什么是这样,我怎样才能让cURL的输出进入正确的日志文件?
根据这个问题的一些答案,PHP会logging到默认的Apache服务器日志(error.log),因为您已经注意到了。 你可以像这样设置php日志设置:
<VirtualHost *:443> ServerName example.com ServerAlias www.example.com # *snip* ErrorLog ${APACHE_LOG_DIR}/example.com_error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined php_flag log_errors on php_flag display_errors on php_value error_reporting 2147483647 php_value error_log ${APACHE_LOG_DIR}/php.error.log </VirtualHost>
另外,在这个问题中的一个答案提到完全在php.ini中设置error_log指令来login到相关的虚拟主机的日志,例如example.com_error.log 。
根据curl文档 ,你可以用CURLOPT_STDERR来设置日志文件的位置。
在这个答案中看到完整的例子