php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30668 error_log ini inconsistent
Submitted: 2004-11-03 00:47 UTC Modified: 2004-11-05 00:05 UTC
From: kauschovar at sdk dot ath dot cx Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.3.9 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kauschovar at sdk dot ath dot cx
New email:
PHP Version: OS:

 

 [2004-11-03 00:47 UTC] kauschovar at sdk dot ath dot cx
Description:
------------
The php.ini setting 'error_log' doesn't seem to behave according to its description in the manual: http://www.php.net/manual/en/ref.errorfunc.php.  It also does not behave consistently between Apache 1.3 and Apache 2.

In both versions of Apache, 'error_log' can not be overridden in httpd.conf, .htaccess, or by ini_set().  The example script below demonstrates that.  Only changes made to php.ini seem to be recognized.  This contradicts the manual, which says that 'error_log' has a changeable property of PHP_INI_ALL, meaning that it can be changed in any of the places I mentioned above.

In Apache 2, if 'error_log' is set in php.ini then it will log to the appropriate file, but it will still not recognize changes made in any other fashion.

In Apache 1.3, PHP will always log to Apache's error_log (/var/log/apache/error_log on my system) regardless of what 'error_log' is set to.  Considering the stern warning against using Apache 2 (http://www.php.net/manual/en/faq.installation.php#faq.installation.apache2), I think making 'error_log' work with Apache 1 is important.

Of course, 'log_errors' is enabled during all of this, I restarted Apache every time I changed a setting in php.ini, httpd.conf or .htaccess, and I made sure that the specified log file was writable by apache (indeed it successfully wrote to it when testing Apache 2, so I know that permissions are okay).

I tested this on two different machines with both Apache 1 and Apache 2, but both machines are running Gentoo Linux.  I  don't have a machine with a different Operating system to confirm this bug with.

Reproduce code:
---------------
<?php

echo '<pre>';
ini_set('error_log', 'php_error_log');
var_dump(get_cfg_var('error_log'));
echo '</pre>';

// 404.html doesn't exist. This will trigger an error which is
// supposed to be logged to the file set by 'error_log'
require_once '404.html';

?>

Expected result:
----------------
Excepted to see a warning about PHP failing to open 404.html in my log file set by 'error_log'.  Also, expected to be able to override the value set by php.ini in httpd.conf, .htaccess, or by ini_set().

Actual result:
--------------
From the var_dump():
string(39) "/var/www/localhost/htdocs/phperrors.log"

... which is the value I set in my php.ini.

Additionally (with Apache 1.3), I expected to see "Warning: main(404.html): failed to open stream" and "Fatal error: main(): Failed opening required '404.html'" in phperrors.log, but instead they appeared in Apache's error_log.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-04 08:49 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Use ini_get() instead of get_cfg_var() as the latter always returns values from php.ini and will not show values altered  with ini_set().
 [2004-11-04 23:06 UTC] kauschovar at sdk dot ath dot cx
You're right about ini_get().  But the fact is that PHP is still logging to the wrong log file.  Furthermore, it's inconsistent between Apache 1 and Apache 2.  It doesn't work *at all* with Apache 1 (the version of Apache recommended by the PHP team).
 [2004-11-05 00:05 UTC] kauschovar at sdk dot ath dot cx
Nevermind.  I rebuilt PHP manually (instead of using Gentoo's packaging system), and it seems to be working now.  Although I did have to look through the C code for php_log_err() before I could get it to work.  Anyways, I'm re-closing this bug report  while I track down the source of the original error since it doesn't seem to be a bug in PHP.  Sorry to bother you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 17 14:01:27 2024 UTC