fluent / NLog.Targets.Fluentd

Apache License 2.0
44 stars 31 forks source link

Added JSON parsing support for json map values #2

Closed jalalahmad closed 8 years ago

jalalahmad commented 8 years ago

Was unable to send json data appropriately. Added supoport for json parsing. settings added to control, useJsonParsing to enable or disable. If enabled it parses the message for json data and sends as individual fields for peoper json formatted data.

moriyoshi commented 8 years ago

While I would find this handy in a practical sense, NLog itself isn't so much designed to be a structured logging facility as this plugin isn't supposed to decode stringized JSON messages to get them ready on wire. Ideally using some other structured logging library such as serilog or semantic logging with a fluent backend appears to be the better way to go. What do you think of this?

jalalahmad commented 8 years ago

Technically you are correct, I agree. However, community benefit wise it might be good. The adoption of NLog as logging framework is large. There is no other direct target for fluentd except this one. Another workaround my peers have used is use a network type target in NLog to achieve nearly same but it does not offer same ease of use. Adding another framework for logging might deter a lot of developers. Options I can think of is, either we offer this as feature in this target or create another target for the same for NLog and call it maybe 'StructuredFluentDTarget' or something similar. Having said that, I would like to hear your thoughts in terms of community benefit and approach we can take.

jalalahmad commented 8 years ago

Also I see Serilog has sync for NLog. Maybe you are right about the approach of using Serilog.

jalalahmad commented 8 years ago

I will close this request, I agree with your approach. Thanks for sharing insight.

snakefoot commented 6 years ago

Think it is a good idea to allow capture of additional properties, even if not support structured logging.

Instead of using this target, then it should be possible to use the NLog-NetworkTarget together with the JsonLayout. This will take the Json-Layout-output and encode to UTF8 and send to fluentd using TCP.

Just like done here:

https://github.com/VQComms/Serilog.Sinks.Fluentd.Core/blob/master/src/Sinks/FluentdSink.cs

"ts":"{timestamp}",
"ticks":"{timestamp-as-ticks}",
"msgtmpl":"{message-raw}",
"level":"{level}",
"{exception-as-json}",
"{propertyname}":"{propertyvalue}",

Btw. NLog 4.5 will support structured logging by default, and handle message-template and capture properties.