Graylog2 with Symfony 2 (Monolog)
Asked Answered
D

1

10

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"

My SF2 config.yml:

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

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

What is wrong here?

Downstairs answered 10/9, 2014 at 11:58 Comment(1)
What's your specific symfony version? Or better yet, can you paste the output you get from composer show --installed?Nicky
D
8

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 @ all

Downstairs answered 10/9, 2014 at 12:47 Comment(1)
Hi, that's great! Maybe you could also add the final configuration with everything in place? Thanks!Bole

© 2022 - 2024 — McMap. All rights reserved.