Symfony 4 生产模式错误处理页面内存耗尽 [英] Symfony 4 Production Mode ErrorHandling Pages Memory Exhausted
问题描述
我在 .env
中将我的项目设置为 prod
模式,并且除了自定义错误页面之外的所有内容似乎都可以正常工作.
我将此作为我的 404 树枝模板:
{# templates/bundles/TwigBundle/Exception/error404.html.twig #}{% 包含 'builder/layout/header.html.twig' 和 {'title': '404'} %}<img src="{{ assets('img/not-found.jpeg') }}";class="img-responsive";id="error-not-found-img";/><div class="http-error-msg-container"><h1>404!未找到页面<p>不要绝望,回到<a href="{{ path('dashboard') }}">首页</a>并重试.</p>
{% 包含 'builder/layout/footer.html.twig' %}
并转到一个不存在的页面(比如 /dashboard/giorgoirdjfisejf
)会返回一个空白页面.所以我将它添加到我的 index.php
文件中:
ini_set('display_errors', 1);ini_set('display_startup_errors', 1);错误报告(-1);
显示错误,我得到了这个:
<块引用>致命错误:第 107 行/var/www/solomon/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php 中允许的内存大小为 134217728 字节(试图分配 20480 字节)
致命错误:第 1 行/var/www/solomon/vendor/symfony/debug/Exception/OutOfMemoryException.php 中允许的内存大小为 134217728 字节(试图分配 32768 字节)
我不太清楚为什么这会导致错误并且无法调试.var/log/prod.log
不显示任何内容,我该如何解决或更好,我该如何调试?
更新
我的 prod/monolog.yaml 文件
独白:处理程序:主要的:类型:finger_crossedaction_level: 错误处理程序:嵌套exclude_404s:# regex: 从日志中排除所有 404 错误- ^/嵌套:类型:流路径:%kernel.logs_dir%/%kernel.environment%.log";级别:调试安慰:类型:控制台process_psr_3_messages: 假频道:[!事件",!教义"]
这是自动生成的,我没有做任何更改
检查 symfony 日志文件的文件权限.看起来 monolog 捕获 permission denied
异常,尝试将其写入日志并一次又一次地捕获相同的错误.
I set my project to prod
mode in .env
and everything aside from the custom error pages seem to work.
I have this as my 404 twig template:
{# templates/bundles/TwigBundle/Exception/error404.html.twig #}
{% include 'builder/layout/header.html.twig' with {'title': '404'} %}
<img src="{{ assets('img/not-found.jpeg') }}" class="img-responsive"
id="error-not-found-img" />
<div class="http-error-msg-container">
<h1>404! Page Not Found</h1>
<p>Don't despair, go back to <a href="{{ path('dashboard') }}">Home</a> and try again.</p>
</div>
{% include 'builder/layout/footer.html.twig' %}
and going to a non-existant page (say /dashboard/giorgoirdjfisejf
) returns a blank page. So I added this to my index.php
file:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
to show the errors and I got this:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/solomon/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /var/www/solomon/vendor/symfony/debug/Exception/OutOfMemoryException.php on line 1
I'm not quite sure why this causes an error and unable to debug. var/log/prod.log
doesn't show anything, how do I resolve or better yet, how do I debug?
update
my prod/monolog.yaml file
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_404s:
# regex: exclude all 404 errors from the logs
- ^/
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine"]
this was auto-generated and I've made no changes
Check file permissions on symfony log files. It looks like monolog catches permission denied
exception, tries to write it to log and catches same error again and again.
这篇关于Symfony 4 生产模式错误处理页面内存耗尽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!