ini_set('error_log', $custom_error_log_location);
print ini_get('error_log');
The result of the above code? Nothing! It literally prints nothing as the value of ini_get('error_log')
. I'm running this on an Apache server. I investigated the Apache configuration for my website. The Apache configuration has its own error log setup through the ErrorLog directive. Here's the thing: I'm running another website on the same server, with a similar Apache configuration, and on that site I CAN specify a custom error log in PHP.
I also checked the site's php.ini file. Nothing on logging there. What I want to know is, is there some configuration in either Apache or php.ini that would prevent me fro开发者_StackOverflowm modifying where the error log file is located?
If safe_mode
or open_basedir
are in effect, ini_set("error_log")
is restricted by those settings (because you can write anything in the opened file with error_log()
).
The restriction covers both runtime and .htaccess
, but you can use the php_value
directive to set it in the virtual host configuration file.
It turns out I had safe_mode
on, that's all.
The error_log
setting belongs to PHP_INI_ALL
which can be set anywhere. So there should be nothing wrong with your code.
By "prints nothing as the value of ini_get('error_log')
", it might be your $custom_error_log_location
is empty or null, I'd suggest a var_dump()
on the $custom_error_log_location
and ini_get('error_log')
for debugging, instead of print.
精彩评论