PHP 8.2: New error_log_mode INI setting to set permissions for error log file

Version8.2
TypeNew Feature

PHP 8.2 introduces a new INI directive named error_log_mode that can be used to configure the file permissions of the PHP error log file (configured with the error_log directive).

Prior to PHP 8.2, PHP automatically set 0644 (equivalent to rw-r--r--, or read/write by the owner, read-only by group and public) as file permissions. 0644 remains the default value for the new error_log_mode directive as well, but it is now possible to configure the error log file permissions via INI settings.

log_errors=1
error_log=error_permissions_test.log
error_log_mode=0644
  • error_log_mode only affects new log files created by PHP. File permissions of existing files are not changed.

  • error_log_mode has a Changeable value of PHP_INI_ALL, and it can be configured in any INI file, command-line parameters, or via ini_set function.

Backwards Compatibility Impact

Declaring error_log_mode INI directive in older PHP versions does not cause any warnings or errors as PHP silently ignores unrecognized INI directives.


Implementation