Closed jalalahmad closed 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?
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.
Also I see Serilog has sync for NLog. Maybe you are right about the approach of using Serilog.
I will close this request, I agree with your approach. Thanks for sharing insight.
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.
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.