Closed ericcoleman closed 5 years ago
Thanks for reporting this. It looks like the library is incorrectly using the shared default Json.NET settings. I believe this failing test demonstrates the error.
[Fact]
public void Ignores_default_settings_while_serialising_to_JSON()
{
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
Converters =
{
new StringEnumConverter()
}
};
var message = new GelfMessage
{
Level = SyslogSeverity.Emergency,
AdditionalFields = new Dictionary<string, object>()
};
var messageJson = message.ToJson();
Assert.DoesNotContain("Emergency", messageJson);
}
I should be able to push out a fix in the next few days, or feel free to put up a PR.
This should do the job. I've published v1.5.1-pre1 with the fix. Let me know if that solves it.
👍 Just tried it out and that fixes the issue. Thanks for your quick response.
No problem, I'll release a stable version shortly.
We're looking at using this Library for logging in our Asp.Net Core 2.1 web api, but we're getting an error in GrayLog.
Our default JSON settings use the
StringEnumConverter
which is causing the SysLogSeverity to not be serialized to an integer.I believe the fix for this is to write a custom JsonConverter for the SysLogSeverity enum, but wanted to get your input on this.