You can also configure PHP to automatically log all script errors to a specific file via the special "log_errors" configuration directive in "php.ini". This directive, when set to true, logs all PHP errors to either a user-specified log file (the value of this file must be specified in the "error_log" configuration directive, also set via "php.ini"), or to the Web server error log if no log file is specified. Consider the following example, which demonstrates: In this case, I'm manually instantiating an error by attempting to include a file which does not exist. Obviously, PHP will barf and display an error screen containing the following: The same error also appears in the server's error log: You can turn off PHP error display, and only have the error message appear in the log file, by setting the "display_errors" variable (also accessible via "php.ini") to false. Consider the following variant of the previous example, which demonstrates: In this case, though an error takes place, it is never displayed to the user, but merely gets logged to the server's error log. On *NIX systems, setting the "error_log" variable to the special value "syslog" logs all errors via the standard "syslog" daemon.
blog comments powered by Disqus |