Closed radiohe4d closed 1 year ago
@radiohe4d thanks for the note!
You're using Serilog to log to Seq, but JsonSafeString
is part of the alternative Seq.Extensions.Logging package, which is a different pipeline altogether.
Serilog doesn't have a similar notion, in part because it doesn't assume that the back-end output format is JSON (or even anything textual).
Seq.Extensions.Logging can do it because at this point and the foreseeable future, it's specifically targeting Seq's HTTP ingestion API.
You might consider switching from Serilog across to S.E.L, but unless you need to do this a lot, you're better off just logging the JSON string, and using FromJson
on the Seq side, e.g.:
FromJson(Answer).A > 40
Alternatively, you could implement an enricher in the Serilog pipeline to parse and transform marked JSON values (using a type like JsonSafeString
) into LogEventPropertyValue
, though it's likely to be a bit tedious.
Let me know if this helps, Nick
Thanks for getting back so quick Nick!
That's where I've made the mistake, I thought S.E.L was a drop in extension, but now that you mention it, it does make more sense that its a replacement for Serilog.
You've given a few great options for next steps, so ill go have a dig around and see what works best.
If I come up with anything useful that could help others I'll drop it back here, but happy for this ticket to be closed for now.
Thanks again 👍
Thanks @radiohe4d 👍
So I've been using Seq successfully now for months and have only now needed to pass a raw JSON string to the logs.
When passing an object and using the @, the logs in the Seq dashboard have shown the JSON formatted and highlighting like so:
I followed this ticket #51 to add this Nuget package and pass the raw JSON using the
new JsonSafeString(json)
struct.I used the exact code from the ticket, but it doesnt appear to be formatting the log within the Seq dashboard as I expect.
Any help would be much appreciated as I cannot figure out why it wont format like the example in ticket 51.
Current Setup:
Seq Server Instance:
Language
C# .NET 6.0
Nuget Packages:
Program.cs
appsettings.json