Archive
This post is archived and may contain outdated information. It has been set to 'noindex' and should stop showing up in search results.
How to Log PHP Errors/Warnings
Mar 4, 2013ProgrammingComments (0)
PHPLogging PHP errors and warnings is important on both your production and development servers. Often times these messages go unnoticed, even if you have display_errors on.

To start logging errors, open up your php.ini file. Scroll down to or search for the line that has the error_log variable. It will probably look like one of these:

;error_log = filename
;error_log = php_errors.log
Semi-colons denote a commented out line in the php.ini file. Any commented out line is ignored by PHP. An unaltered php.ini file should have the error_log line commented out, so the first thing you'll want to do is remove that semi-colon at the start of the line.

Next you want to change the value to your desired log file. I created an empty errors.log text file in my PHP directory and then had errors logged there (make sure you show file extensions if on Windows). So my error_log line now looks like this:

error_log = "C:\Program Files\PHP\errors.log"
I included the full path to remove any ambiguity, and it should be in quotes if you're using a full path like that.

In most cases you'll be done at this point, but there are two common issues people run into. First, double-check to make sure your error_log value is not being overwritten elsewhere in the php.ini file. Do a quick search for all occurrences of error_log. Second, make sure the log file you created can be modified. Putting it in your PHP directory should do the trick, but if not check its security settings.
Comments (0)
Add a Comment
No comments yet