Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Issue

The php.log file is filling up with many notices, coding warnings, and deprecated errors.  This can make it difficult to find more critical errors, and can cause the log size to grow too quickly.

Environment

This article tells how to set the error_reporting directive using the Zend Server 7 User Interface.  The suggested string "E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED" is valid for PHP 5.3 and later.

Resolution

Access the Zend Server User Interface in your web browser at:

http://<your IBM i IP address>:10081

Info
titleThe User Interface may be at a different port.

Depending on the version of Zend server and whether it was installed with a different version, your user interface may be at port 10091 or 10101, instead of 10081 as shown in the above example.


Log in if needed. Go to the Configurations -> PHP tab. Expand the 'Error Handling and Logging' category (click on it).

Look at the 'error_reporting' setting. In the default configuration, the value is this:

E_ALL & ~E_DEPRECATED & ~E_STRICT

This will capture all errors to the php.log file, including many warning messages that you may not care about. You can change this value to something more restrictive. One possible string to use would be this:

E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED

You can see all of the error logging constants with definitions here:

PHP Error Logging Predefined Constants

Learn more about the error_reporting directive here:

PHP: Runtime Configuration

Details

As shipped, Zend Server sets error_reporting to E_ALL & ~E_DEPRECATED & ~E_STRICT, which reports everything.  This is fine in a development environment, as the developer may be interested in all the notices and warnings about strict coding and deprecated functions.  In a production environment, these messages are usually safely ignored, since the developer has had a chance to see them in developing the application and has decided not to address them.  In production, they just take up space in the log.

Some customers may also decide not to show warning messages in production.  Warning messages show something that is a little bit wrong, but won't usually prevent the script from running.  Some people like to see the warnings so they can fix up the scripts, but others don't care so much about them, as long as the application seems to be working OK otherwise.  If you do want to suppress warnings, I don't really recommend it, but will show you how:

E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_WARNING