Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Feature request: Adding numeric field to a gelf message through logback #30

Closed
dklotz opened this issue Feb 10, 2014 · 3 comments
Closed

Comments

@dklotz
Copy link

dklotz commented Feb 10, 2014

At the moment I don't see any way to (dynamically) add a numeric field (with a number, not with a string value) to a message logged through logback-gelf. This would be great to have, because it would allow us to filter, graph etc. these messages in graylog based on that numeric value (e.g. "only warnings for messages where _size > 500"). The MDC seems to be of no help, because it only takes String values for each key.

Any ideas if this is even remotely possible?

@Moocar
Copy link
Owner

Moocar commented Feb 16, 2014

Cool idea, unfortunately you're right about the MDC. It is a map of String,String.

One potential way around this is to associate an expected type with a field name. That way when we pull the fields out of the MDC, we then find the type associated with that field name, then convert the value in the MDC into that type before saving it to json. The interface might look something like this:

<appender  name="GELF" class="me.moocar.logbackgelf.GelfAppender">
  <additionalField type="number">fooField:_foo_field</additionalField>
</appender>

This seems pretty clear to me, but it wouldn't support the includeFullMDC option. For that, we'd need to do something like

<includeFullMDC>true</includeFullMDC>
<fieldType>_foo_field:number</fieldType>

That one seems a bit more ugly to me. Out of interest, in your case, are you using includeFullMDC or are you specifying specific additionalFields?

@dklotz
Copy link
Author

dklotz commented Feb 17, 2014

We're using includeFullMDC. Being able to override the type for specific fields (either through the existing additionalField with an an added type parameter or through a new fieldType option or similar) would be a great way to enable this while still staying with the normal logback API in code.

pktxu pushed a commit to pktxu/logback-gelf that referenced this issue Feb 25, 2014
pktxu pushed a commit to pktxu/logback-gelf that referenced this issue Mar 3, 2014
pktxu pushed a commit to pktxu/logback-gelf that referenced this issue Mar 3, 2014
Moocar added a commit that referenced this issue Apr 2, 2014
add support for field type conversion #30
@Moocar
Copy link
Owner

Moocar commented Apr 2, 2014

Feature implemented as part of #31. Enjoy :) (thanks @pktxu)

@Moocar Moocar closed this as completed Apr 2, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants