On production web sites, displaying all warnings or error messages are not recommended because this may reveal security information to end users, such as file paths on your Web server, your database schema or other information.
Saving all error log messages is a better idea. It’s very easy to turn this feature on if you’re on apache with ini_set function.
However, it’s quite complex if you’re running PHP on IIS, you need to have permission to modify the php.ini file and restart the IIS service.
Steps to save php error log message in IIS
- 1. Open your php.ini file (ex: C:\WINDOWS\php.ini or C:\PHP\php.ini)
- 2. Make sure log_errors directive is on to enable log errors into a log file. If not, change its value to On like this:
log_errors = On
- 3. Change error_log directive value with a full path of a file you wish to save the error messages. For example:
error_log = "C:/PHP/error_log.txt"
Note: the file must be existed and can be write by everyone or the IUSR account.
- 4. Restart the IIS Service
A piece of my php.ini related to the error log configuration:
; Print out errors (as a part of the output). For production web sites, ; you're strongly encouraged to turn this feature off, and use error logging ; instead (see below). Keeping display_errors enabled on a production web site ; may reveal security information to end users, such as file paths on your Web ; server, your database schema or other information. display_errors = off ; Even when display_errors is on, errors that occur during PHP's startup ; sequence are not displayed. It's strongly recommended to keep ; display_startup_errors off, except for when debugging. display_startup_errors = Off ; Log errors into a log file (server-specific log, stderr, or error_log (below)) ; As stated above, you're strongly advised to use error logging in place of ; error displaying on production web sites. log_errors = On error_log = "C:/PHP/error_log.txt" ; Set maximum length of log_errors. In error_log information about the source is ; added. The default is 1024 and 0 allows to not apply any maximum length at all. log_errors_max_len = 1024 |