在开发过程中,我们在获取代码的真实错误日志时遇到了一些问题。
nginx->带有laravel的php-fpm
无法获取laravel的日志
www.conf
[www]
user = www-data
group = www-data
listen = 127.0.0.1:9000
clear_env = no
catch_workers_output = yes
pm = dynamic
pm.max_children = 200
pm.start_servers = 80
pm.min_spare_servers = 50
pm.max_spare_servers = 80
pm.max_requests = 250
request_terminate_timeout = 60
slowlog = /var/log/error.log
php_flag[display_errors] = on
php_admin_value[error_log] = /var/log/error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /usr/local/lib/session
php_value[soap.wsdl_cache_dir] = /usr/local/lib/wsdlcache
;php_value[opcache.file_cache] = /usr/local/lib/opcache
;monitoring
pm.status_path = /phpfpm_status
ping.path = /phpfpm_ping
ping.response = pong
php.ini
error_log = "/var/log/error.log"
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE
display_errors = On
display_startup_errors = On
...
php-fpm.conf
include=/usr/local/etc/php-fpm.d/*.conf
[global]
error_log = "/var/log/error.log"
log_level = notice
events.mechanism = epoll
我已经为/var/log/error.log和access.log文件添加了全部权限 现在,我只能在access.log和error.log中获得php-fpm登录
/var/log # cat error.log
[20-Mar-2019 06:08:34] NOTICE: fpm is running, pid 9
[20-Mar-2019 06:08:34] NOTICE: ready to handle connections
/var/log # cat access.log
172.28.0.5 - 20/Mar/2019:06:34:12 +0000 "GET /index.php" 200
172.28.0.5 - 20/Mar/2019:06:34:18 +0000 "POST /index.php" 200
/var/log # pwd
/var/log
寻找答案
答案 0 :(得分:1)
将stderr / stdout添加到config / logging.php中的日志记录堆栈中
在此之前已经讨论过了,泰勒在laravel附带的config / logging.php中为stderr输出(php:// stderr)添加了一个示例。 https://github.com/laravel/ideas/issues/126
或仅更改.env LOG_CHANNEL示例,引用原始注释:https://github.com/laravel/ideas/issues/126#issuecomment-438548169
在最新版本(5.6+)中,默认config / logging.php似乎可以 包括stderr配置,因此您只需注入LOG_CHANNEL = stderr 环境变量放入容器中。
这会将基于您的日志记录级别的所有错误/日志重定向到docker日志