Nlog: JSON serialization of doubles

Created on 23 Aug 2018  路  2Comments  路  Source: NLog/NLog

NLog version: 4.5.6

Platform: .Net 4.5

I just ran into an issue/inconsistency using JSON formatted logs. It turns out that NaN, PositiveInfinity, and NegativeInfinity are not valid symbols for a double according to the JSON spec,
however, they serialize as symbols in the NLog JSON Serializer.

Example output:
"Segment": { "Name": "Processing", "Requested": "2018-06-14T23:06:43.9029798Z", "Finished": "2018-06-14T23:07:20.2739469Z", "Valid": true, "EstimatedRemaining": NaN, "Elapsed": 36.3709671 },

There's a lot of discussion about this in various places online. The common workarounds seem to be either converting it to a string ("NaN") or replacing it with null or 0.

The reason this is having an impact is that the deserializer used in our log aggregator doesn't recognize the log message as valid JSON and refuses to parse it.

bug json / json-layout

All 2 comments

Created PR #2861 @jkoplo Thank you for reporting this.

@jkoplo NLog 4.5.9 has been released: https://www.nuget.org/packages/NLog

Once again thank you for reporting this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MaximRouiller picture MaximRouiller  路  3Comments

JustArchi picture JustArchi  路  3Comments

carkov1990 picture carkov1990  路  3Comments

linmasaki picture linmasaki  路  3Comments

FaMouZx3 picture FaMouZx3  路  3Comments