LoginSignup
8
11

More than 5 years have passed since last update.

Apache のログレベルと PHP エラーログの関係

Last updated at Posted at 2017-01-19

デフォルトでは PHP のエラーは Apache のエラーログ /var/log/httpd/error_log に出力される。
この場合、PHP のエラー出力が Apache の LogLevel の設定に影響を受けるのかを検証した。

検証環境

  • CentOS 7.3.1611 (minimal)
  • Apache 2.4.6 (base)
  • PHP 5.1.6 (base)

LogLevel と PHP エラー出力の対応表

LogLevelerror 以下に設定すると PHP エラーが出力できることを確認した。
なお、デフォルトでは LogLevelwarn に設定されている。
error_log を設定して Apache のエラーログとは異なるファイルに出力した場合は LogLevel の設定の影響を受けない。

LogLevel 出力
emerg ×
alert ×
crit ×
error
warn
notice
info
debug

エラー出力レベルと出力内容の対応表

error_reporting の設定と実際に出力されるエラー内容を確認した。
Apache の LogLevelerror 以下であればどの LogLevel でも差はなかった。

エラー 未指定 E_ALL E_DEPRECATED E_STRICT E_NOTICE E_PARSE E_WARNING E_ERROR
error_log()
PHP Parse error
PHP Deprecated
PHP Strict Standards
PHP Notice
PHP Warning
PHP Fatal error

エラー確認用ソースコード

error_log('error_log()');
~                                // PHP Parse error
$d =& dir('/');                  // PHP Strict Standards
set_magic_quotes_runtime(false); // PHP Deprecated
echo $undefined;        // PHP Notice
ini_set();                       // PHP Warning
undefined();                     // PHP Fatal error
8
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
11