Logging in PHP
Applications written in PHP generate log messages whenever an error occurs. These messages may be saved to a log file, passed to syslog, or ignored, depending on the configuration settings of the interpreter. Ignoring error messages is a bad idea as it prevents you from detecting problems occurring on your server.
On the other hand, saving every message to a file can cause your logs to grow very quickly, especially on high-traffic sites. Fortunately, PHP allows you to configure which errors are logged quite precisely. All PHP errors are assigned a level value; most severe errors are marked as E_ERROR
, less severe as E_WARNING
, even less severe as E_NOTICE
, and so on. A complete list of error levels can be found in the PHP manual at http://php.net/errorfunc.constants.php.
It is recommended to log all errors during development, but in production, all errors should be logged, except E_DEPRECATED
(deprecation warnings) and E_STRICT
(code style suggestions). We will set this level...