I have a website running using Apache 2.2.22, PHP 5.3.10, and cURL 7.2.00. The relevant portions of the apache config is below, and you will notice that errors are sent to 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>
However, when I use cURL from within PHP and turn verbose logging on using curl_setopt($connection, CURLOPT_VERBOSE, true);
the output from cURL goes into Apache's error.log
instead of the custom logfile I defined above. Why is this, and how can I get cURL's output to go into the correct log file?
Per some answers to this SO question, php logs to the default Apache server log (error.log) as you've already noticed. You can set the php log settings like so:
Alternatively, one answer in that SO question mentioned unsetting the
error_log
directive completely in php.ini to log to the relevant virtual host's logs, e.g.example.com_error.log
.According to curl documentation, You can set log file location with CURLOPT_STDERR.
See complete example in this answer