简体   繁体   中英

I can't specify a custom error log in PHP

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 from 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.

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.

事实证明,我已启用safe_mode ,仅此safe_mode

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM