Lamp架构下,php错误日志与apache配置自身的错误日志ErrorLog的区别

php错误日志与apache配置自身的错误日志ErrorLog的区别
apache配置错误日志语法:

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/etc/httpd"
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog "logs/error_log"

分析:

在mod_php的SAPI接口场景下:

只有在mod_php的SAPI接口场景且php.ini的error_log参数没有被配置的情况(包括error_log配置了但为空的情况),php的报错信息才会记录到apache的ErrorLog配置所记录的错误日志中,在mod_php模式下,该mod_php模块被集成到apache内部,因此mod_php作为apache的一个组成部分出现,因此apache能对php实现更多更精准的控制。(此种情况下,该httpd.conf中的错误日志配置的ErrorLog路径文件,将同时记录apache的web运行的错误日志(如httpd服务重启等,会被记录)和php执行的错误日志)。

cgi/fcgi的SAPI(如php-fpm)接口场景:

如果是cgi/fcgi的SAPI(如php-fpm)且php.ini的error_log参数没有被配置的情况(包括error_log配置了但为空的情况,如果用php-fpm,那么php-fpm的对error_log的配置也应该是没有配置或者配置了为空),php的报错信息才会记录到apache的ErrorLog配置所记录的错误日志中。(此种情况下,该httpd.conf中的错误日志配置的ErrorLog路径文件,将同时记录apache的web运行的错误日志(如httpd服务重启等,会被记录)和php执行的错误日志),(如果php-fpm与php.ini都配置了error_log,当通过php-fpm作为SAPI执行php的时候,php-fpm的配置将重写php.ini中的配置.)

综述:

只要php的运行时状态时,error_log的值不是not value,即存在有效路径值(可以通过php.ini,php-fpm配置,ini_set,apache的php_value等多种方法设置),那么php的错误日志就会被记录到该错误日志路径中。否则错误日志将记录到lamp架构中的httpd.conf中的ErrorLog配置文件中。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值