Jump to content

[SOLVED] trying to write errors to a log file instead of the browser


mottwsc

Recommended Posts

I'm forcing an error by purposely leaving out an include file that has db login information in it.  When I render the php page, and get to the connection statement

$cxn = mysqli_connect($host,$user,$password,$dbname) 
            or die ("Couldn't connect to server.".mysqli_error($cxn));

I get the message 'Couldn't connect to server.'

 

That makes sense.  The problem is that I am trying to not have this error display, but instead write the error to a log file that I've specified (which is set up in another directory for security reasons).  I have modified the php.ini file so that:

error_reporting  =  E_ALL

display_errors = Off

log_errors = On

error_log = c:/php/log/phplog.txt

 

Unfortunately, I still see the error in the browser and it is not written to the log file.

 

What still needs to be adjusted so that the error is not shown in the browser but is instead written to the log file?

 

Thanks!

I've tried both trigger_error and error_log, but I get the same result.  No custom error is written to either the screen or the log file.  Only the generaic error message is written to the screen.  Maybe there is something I'm not setting in the ini file?  Or maybe I need to use custom error handing with this (although I thought I read that this would work with standard error handling)?

 

If display_errors is turned off it shouldn't display any errors. The error will be written to the error log file instead.

 

Are you sure PHP is reading the php.ini you are editing. Confirm this by running the phpinfo() function and looking at the Loaded Configuration File line.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.