2
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?

RobertPitt
  • 56,863
  • 21
  • 114
  • 161
William
  • 33
  • 1
  • 4
  • Obvious question, is `$custom_error_log_location` set correctly? – Jake N Feb 12 '11 at 20:15
  • Yes, it is. By any chance, and this is a long shot, does PHP validate the path and replace it with a blank value if the validation fails? – William Feb 12 '11 at 21:20

3 Answers3

3

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.

aaz
  • 5,136
  • 22
  • 18
  • Yes, it was that blasted safe_mode to blame. – William Feb 13 '11 at 00:00
  • Got on this question googling for "php.ini error_log value is error_log" in my phpinfo I can see error_log and it's value is error_log. Do you know in what directory I should be looking? – HMR Jun 10 '14 at 07:21
1

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.

gmadd
  • 1,146
  • 9
  • 18
howanghk
  • 3,070
  • 2
  • 21
  • 34
1

It turns out I had safe_mode on, that's all.

William
  • 33
  • 1
  • 4