[GH-ISSUE #18] GELF handler #4

Closed
opened 2026-03-04 02:11:15 +03:00 by kerem · 12 comments
Owner

Originally created by @jippi on GitHub (Apr 26, 2011).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/18

Hi,

I would like to add a GELF handler to the stack, but I'm missing a feature that you might can help me add.

I plan to use https://github.com/Graylog2/gelf-php as base for the gelf handler

I noticed that addRecord has an "extra" array key, but its unused? Whats the plan for it?

Originally created by @jippi on GitHub (Apr 26, 2011). Original GitHub issue: https://github.com/Seldaek/monolog/issues/18 Hi, I would like to add a GELF handler to the stack, but I'm missing a feature that you might can help me add. I plan to use https://github.com/Graylog2/gelf-php as base for the gelf handler I noticed that addRecord has an "extra" array key, but its unused? Whats the plan for it?
kerem closed this issue 2026-03-04 02:11:16 +03:00
Author
Owner

@Seldaek commented on GitHub (Apr 27, 2011):

This looks cool, didn't know of Graylog. What is that feature that is missing?

The extra key btw can be used by Processors to add extra metadata to a record. It's then used by the formatters as they see fit.

<!-- gh-comment-id:1063995 --> @Seldaek commented on GitHub (Apr 27, 2011): This looks cool, didn't know of Graylog. What is that feature that is missing? The extra key btw can be used by Processors to add extra metadata to a record. It's then used by the formatters as they see fit.
Author
Owner

@jippi commented on GitHub (Apr 27, 2011):

I think monolog lacks the possibility to add extra data to the log event, besides from severity and message - GELF supports a very rich interface of custom fields and formats.

<!-- gh-comment-id:1064200 --> @jippi commented on GitHub (Apr 27, 2011): I think monolog lacks the possibility to add extra data to the log event, besides from severity and message - GELF supports a very rich interface of custom fields and formats.
Author
Owner

@Seldaek commented on GitHub (Apr 27, 2011):

Well as I described you can store it in the extra key via a processor, which could itself be attached to the GelfHandler. What kind of data are we talking about here?

<!-- gh-comment-id:1064828 --> @Seldaek commented on GitHub (Apr 27, 2011): Well as I described you can store it in the extra key via a processor, which could itself be attached to the GelfHandler. What kind of data are we talking about here?
Author
Owner

@jippi commented on GitHub (Apr 27, 2011):

Could really be anything :)

For example: https://github.com/Graylog2/gelf-php/blob/master/index.php

<!-- gh-comment-id:1065071 --> @jippi commented on GitHub (Apr 27, 2011): Could really be anything :) For example: https://github.com/Graylog2/gelf-php/blob/master/index.php
Author
Owner

@Seldaek commented on GitHub (Apr 27, 2011):

Right, well the thing is that the message does not have to be a string actually, so in your application, if you know that you have a gelf handler (and a gelf handler only I'd think), you could pass GELFMessage instances to addRecord(), and have your handler re-use them and eventually add/change some more information like the level etc.

To me though most of that could be achieve via a Processor. I don't have much time right now but maybe next week I can look into this a bit. If you can create a patch for a GelfHandler already it'd be cool. Would be nice to know what the license is on that Gelf-php, if we need to bundle it in Monolog..

<!-- gh-comment-id:1065310 --> @Seldaek commented on GitHub (Apr 27, 2011): Right, well the thing is that the message does not have to be a string actually, so in your application, if you know that you have a gelf handler (and a gelf handler only I'd think), you could pass GELFMessage instances to addRecord(), and have your handler re-use them and eventually add/change some more information like the level etc. To me though most of that could be achieve via a Processor. I don't have much time right now but maybe next week I can look into this a bit. If you can create a patch for a GelfHandler already it'd be cool. Would be nice to know what the license is on that Gelf-php, if we need to bundle it in Monolog..
Author
Owner

@shaneog commented on GitHub (Jul 6, 2011):

Has anyone looked at/worked on this issue? If not I might have a bash at it

<!-- gh-comment-id:1512286 --> @shaneog commented on GitHub (Jul 6, 2011): Has anyone looked at/worked on this issue? If not I might have a bash at it
Author
Owner

@Seldaek commented on GitHub (Jul 6, 2011):

Nope, feel free - there's by the way that new $context argument that was introduced on Logger::addRecord since this issue was created, which could be used to pass an exception object for example, or anything that could be handled by a GelfFormatter to add extra data (backtrace & the like) for the GelfHandler.

<!-- gh-comment-id:1512322 --> @Seldaek commented on GitHub (Jul 6, 2011): Nope, feel free - there's by the way that new $context argument that was introduced on Logger::addRecord since this issue was created, which could be used to pass an exception object for example, or anything that could be handled by a GelfFormatter to add extra data (backtrace & the like) for the GelfHandler.
Author
Owner

@shaneog commented on GitHub (Jul 6, 2011):

I'm just going through the Monolog source now to get a feel for it and will try to work on something in the next couple of days

<!-- gh-comment-id:1512403 --> @shaneog commented on GitHub (Jul 6, 2011): I'm just going through the Monolog source now to get a feel for it and will try to work on something in the next couple of days
Author
Owner

@Seldaek commented on GitHub (Jul 6, 2011):

Sure, no rush, the goal is to push 1.0 out ASAP anyway, for inclusion in Symfony2.0, then we'll see about adding extra handlers for 1.1.

<!-- gh-comment-id:1512420 --> @Seldaek commented on GitHub (Jul 6, 2011): Sure, no rush, the goal is to push 1.0 out ASAP anyway, for inclusion in Symfony2.0, then we'll see about adding extra handlers for 1.1.
Author
Owner

@mlehner commented on GitHub (Feb 22, 2012):

I wrote a GelfHandler for my own project and am currently using it. I'd love to contribute it back to the community.

My concern is how to package the Gelf specific classes. Right now it's in a separate namespace outside of Monolog. Any suggestions how this should be handled?

<!-- gh-comment-id:4126596 --> @mlehner commented on GitHub (Feb 22, 2012): I wrote a GelfHandler for my own project and am currently using it. I'd love to contribute it back to the community. My concern is how to package the Gelf specific classes. Right now it's in a separate namespace outside of Monolog. Any suggestions how this should be handled?
Author
Owner

@stof commented on GitHub (Feb 22, 2012):

You could create a separate library for Gelf which would be an optional deps for Monolog if these classes make sense without Monolog. Otherwise, simply put them in Monolog, in a Monolog\Gelf namespace or something like that

<!-- gh-comment-id:4126730 --> @stof commented on GitHub (Feb 22, 2012): You could create a separate library for Gelf which would be an optional deps for Monolog if these classes make sense without Monolog. Otherwise, simply put them in Monolog, in a `Monolog\Gelf` namespace or something like that
Author
Owner

@Seldaek commented on GitHub (Apr 22, 2012):

#61 has now been merged, please give it a try.

<!-- gh-comment-id:5268806 --> @Seldaek commented on GitHub (Apr 22, 2012): #61 has now been merged, please give it a try.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#4
No description provided.