我已经使用了以下配置来记录我的生产日志:
monolog:
handlers:
mail:
type: fingers_crossed
action_level: error
handler: grouped
grouped:
type: group
members: [streamed, buffered]
streamed:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
# buffered is used to accumulate errors and send them as batch to the email address
buffered:
type: buffer
handler: swift
swift:
type: swift_mailer
from_email: info@....com
to_email: info@....com
subject: Error Occurred!
level: debug
这将发送这样的电子邮件:
[2012-03-21 21:24:09] security.DEBUG: 从会话中读取SecurityContext [] []
[2012-03-21 21:24:09] security.DEBUG: 从用户提供者重新加载用户。 [] []
[2012-03-21 21:24:09] security.DEBUG: 用户名“jakob.asdf”已从用户提供者重新加载。 [] [] [2012-03-21 21:24:09] request.INFO:匹配路由“_user_settings”(参数:“_controller”:“...Bundle\Controller\UserController ::settingsAction”,“username”:“Jakob.asdf”,“_route”:“_user_settings”)[] []
[2012-03-21 21:24:09] request.ERROR:Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException:... Bundle \ Entity \ User对象未找到。(未捕获异常)位于/var/www/.../vendor/bundles/Sensio/Bundle/FrameworkExtraBundle/Request/ParamConverter/DoctrineParamConverter.php 行50 [] []
[2012-03-21 21:24:09] security.DEBUG: 在会话中写入SecurityContext [] []
我真的希望在这里有一个堆栈跟踪,或者至少是触发错误的控制器中的行号。否则就需要猜测问题可能出在哪里。
现在的问题是:是否有任何方法可以实现这样更详细的日志记录?