带有Symfony 2的Graylog2(Monolog) [英] Graylog2 with Symfony 2 (Monolog)

查看:100
本文介绍了带有Symfony 2的Graylog2(Monolog)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在SF2项目中使用"Monolog-> GelfHandler".因此,我将以下内容添加到了composer.json中:

I want to use the "Monolog -> GelfHandler" in a SF2 project. So I've added the following to my composer.json:

"graylog2/gelf-php": "dev-master"

我的SF2 config.yml:

My SF2 config.yml:

monolog:
    handlers:
        main:
            type: gelf
            publisher:
                hostname: %Graylog2.Host%
                port: %Graylog2.Port%
            level: info
            formatter: monolog.formatter.session_request

但是现在,如果我想记录一些内容,则会在GelfHandler :: write()中收到错误消息

But now, if I want to log something, I get an error in GelfHandler::write()

Gelf\Publisher::publish() must be an instance of Gelf\MessageInterface, string given

这是怎么了?

推荐答案

好的,我会亲自回答我的问题.失败是因为更改了格式化程序",或者您必须使用格式化程序是 Monolog \ Formatter \ GelfMessageFormatter 的子类.

ok, i will answer my question by my self. the failure is to change the "formatter" or you have to use a formatter is sub-classes from Monolog\Formatter\GelfMessageFormatter.

thx @全部

这篇关于带有Symfony 2的Graylog2(Monolog)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆