gpt4 book ai didi

php - 我怎样才能在 php-fpm 后面的 docker 中获取 laravel 的日志?

转载 作者:行者123 更新时间:2023-12-05 01:41:01 27 4
gpt4 key购买 nike

在开发过程中,我们在获取代码的真实错误日志时遇到了一些问题。

架构

nginx -> 带有 laravel 的 php-fpm

问题

获取不到laravel的日志

环境

  • 图片 php:7.2.8-fpm-alpine3.7
  • docker 18.06.1-ce
  • laravel 5.5

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现在,我只有 php-fpm 登录 access.log 和 error.log

/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

寻找答案

最佳答案

将 stderr/stdout 添加到 config/logging.php 中的日志堆栈

这之前在这里讨论过,Taylor 在 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

In recent versions (5.6+) the default config/logging.php appears to include a stderr config, so you can just inject a LOG_CHANNEL=stderr environment variable into the container.

这将根据您的日志记录级别将所有错误/日志重定向到 docker 日志

关于php - 我怎样才能在 php-fpm 后面的 docker 中获取 laravel 的日志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55254973/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com