markmcdowell / NLog.Targets.ElasticSearch

NLog target for Elasticsearch
MIT License
176 stars 89 forks source link

feat: Skip jsonserialize of System.Net.IpAddress since properties throws exceptions #130

Closed snakefoot closed 4 years ago

snakefoot commented 4 years ago

Trying to resolve #129 when using MaxRecursionLimit="2". Better handling of Microsoft-Logger output on LogRequestFinished in AspNetCore.

Also discovered that ExpandoObject-logic doesn't work well with JsonToStringConverter. Now changed JsonToStringConverter to generate output for an json-object so it can be converted into ExpandoObject:

2020-07-09 09:42:56.2691 Error ElasticSearch: Error while formatting property: MethodInfo Exception: System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Dynamic.ExpandoObject'.
   at NLog.Targets.ElasticSearch.StringExtensions.ToExpandoObject(String field, JsonSerializer jsonSerializer)
   at NLog.Targets.ElasticSearch.ObjectConverter.FormatToExpandoObject(Object value, JsonSerializer jsonSerializer)

Checklist

snakefoot commented 4 years ago

@markmcdowell Ready for review