Reputation: 143
I've narrowed my problem down somewhat.
When I run "error_log('hey');"
from the command line it dumps to STDOUT. But if I run the same code from my web interface (Apache) it puts the error in the error log.
I've checked both ini files, the one Apache is using, and the one in /private/etc (I'm on a Mac running MAMP). Both error_log variables point to the exact same place.
And when I run
echo ini_get('error_log');
The value is the same on the command line as it is in the browser. What ini setting is misconfigured here? This is quite annoying, as more than just error logging is broken. It's affecting my include paths as well :/
Upvotes: 1
Views: 1661
Reputation: 7386
The relevant ini setting here is display_errors
.
From the command line a value of On
will dump the errors to STDOUT
; stderr
will divert them to STDERR and Off
will suppress them. For Apache only On
and Off
make any sense.
The odds are that the ini file for Apache has display_errors = Off
whilst the one in /private/etc has display_errors = On
.
The error_log
directive tells PHP where to log errors to, but it also requires log_errors
to be set to On
, otherwise it has no effect. (Again, chances are the ini file in /private/etc has log_errors = Off
.)
Upvotes: 0
Reputation: 401182
A reason for error_log displaying in the console, and not in the log file might be because of a problem with permissions -- I don't really know MacOS, but as it's UNIX-based, I'm guessing that :
If it can't log to the log file, I suppose that error_log is writting to the standard output for error (stderr), which is generally the console.
This comment on the manual's page seems to indicate this might be the cause of your problems (quoting) :
it seems that PHP logs to stderr if it can't write to the log file. Command line PHP falls back to stderr because the log file is (usually) only writable by the webserver.
Also, make sure the log_errors
and display_errors
are properly configured in the php.ini file used in CLI :
log_errors boolean
Tells whether script error messages should be logged to the server's error log or error_log. This option is thus server-specific.
And :
display_errors string
This determines whether errors should be printed to the screen as part of the output or if they should be hidden from the user.
Value "stderr" sends the errors to stderr instead of stdout.
Upvotes: 0
Reputation: 11070
What are you trying to accomplish? Within apache, stderr goes into the error_log
... the error_log()
function documentation states that by default it logs to the server's error log. If you want to log to a different destination, use the message_type
and destination
parameters.
Upvotes: 1
Reputation: 2167
You probably need to edit the following config file:
/Applications/MAMP/conf/php5/php.ini
MAMP uses it's own Apache server, which by default runs on port 8080. You probably want to turn off the Apache server in the System Preferences -> Sharing.
Also, try running a PHP file containing:
<?php phpinfo(); ?>
This will tell you which php.ini is actually being read by Apache.
Will
Upvotes: 0