8.18. Logging Errors8.18.1. ProblemYou want to write program errors to a log. These errors can include everything from parser errors and files not being found to bad database queries and dropped connections. 8.18.2. SolutionUse error_log( ) to write to the error log:
8.18.3. DiscussionLogging errors facilitates debugging. Smart error logging makes it easier to fix bugs. Always log information about what caused the error:
You're not getting all the debugging help you could be if you simply log that an error occurred without any supporting information:
Another useful technique is to include the _ _FILE_ _ and _ _LINE_ _ constants in your error messages:
The _ _FILE_ _ constant is the current filename, and _ _LINE_ _ is the current line number. 8.18.4. See AlsoRecipe 8.15 for hiding error messages from users; documentation on error_log( ) at http://www.php.net/error-log.
Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|