我在Symfony2上运行一个应用程序。每当我加载一个页面或一个控制器时,dev.log文件就会被这些行填充成千上万个:
[2017-10-12 15:26:08] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bridge\Monolog\Handler\FirePHPHandler::onKernelResponse". [] []
[2017-10-12 15:26:08] event.DEBUG: Notified event "kernel.response" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\CacheListener::onKernelResponse". [] []
[2017-10-12 15:26:08] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ResponseListener::onKernelResponse". [] []
[2017-10-12 15:26:08] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelResponse". [] []
[2017-10-12 15:26:08] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\Fragment\FragmentHandler::onKernelResponse". [] []
[2017-10-12 15:26:08] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\Security\Http\RememberMe\ResponseListener::onKernelResponse". [] []
[2017-10-12 15:26:08] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelResponse". [] []
[2017-10-12 15:26:08] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener::onKernelResponse". [] []
[2017-10-12 15:26:08] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\StreamedResponseListener::onKernelResponse". [] []
[2017-10-12 15:26:08] event.DEBUG: Notified event "kernel.terminate" to listener "Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onKernelTerminate". [] []
[2017-10-12 15:26:09] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest". [] []
[2017-10-12 15:26:09] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest". [] []
[2017-10-12 15:26:09] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\FragmentListener::onKernelRequest". [] []
[2017-10-12 15:26:09] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest". [] []
[2017-10-12 15:26:09] request.INFO: Matched route "getVersion" (parameters: "domain": "BID", "id": "7694", "_controller": "Sii\StimasBundle\Controller\UpdateFolderController::getVersion", "_route": "getVersion") [] []
[2017-10-12 15:26:09] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest". [] []
[2017-10-12 15:26:09] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". [] []
[2017-10-12 15:26:09] security.DEBUG: Read SecurityContext from the session [] []
[2017-10-12 15:26:09] security.DEBUG: Reloading user from user provider. [] []
[2017-10-12 15:26:09] doctrine.DEBUG: SELECT t0.username AS username1, t0.username_canonical AS username_canonical2, t0.email AS email3, t0.email_canonical AS email_canonical4, t0.enabled AS enabled5, t0.salt AS salt6, t0
...thousands and thousands of the kind of same lines
随着时间的推移,这会使文件变得非常庞大而且非常烦人。
这是我的config_dev.yml文件:
imports:
- { resource: config.yml }
framework:
router: { resource: "%kernel.root_dir%/config/routing_dev.yml" }
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
firephp:
type: firephp
level: info
# chromephp:
# type: chromephp
# level: info
assetic:
use_controller: true
#swiftmailer:
# delivery_address: me@example.com
可能是什么问题以及如何摆脱?
答案 0 :(得分:0)
在config_dev
部分monolog
中,将debug
日志记录级别更改为某个更高级别,例如info
或“错误”'。
monolog:
handlers:
main:
type: stream
path: '%kernel.logs_dir%/%kernel.environment%.log'
level: debug
channels: ['!event']
您可能还需要设置fingers_crossed
来保存调试消息,但只有在发生错误时,here才是文档。
另一种方法是禁用特定的错误记录通道。
在channels
下添加['!event', '!doctrine', '!security']
以忽略特定渠道:" event"," doctrine"," security"相应
答案 1 :(得分:0)
我会保持启用调试选项,我将使用File Rotation:
# app/config/config_dev.yml
monolog:
handlers:
main:
type: rotating_file
path: '%kernel.logs_dir%/%kernel.environment%.log'
level: debug
# max number of log files to keep
# defaults to zero, which means infinite files
max_files: 10
我目前使用的是什么,而且根本不会打扰我,这样我就可以保留调试消息,以防我需要和固定数量的文件。
或....如果你愿意,你可以混合两种解决方案。