-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streaming events: can't deserialize Trace
level (writing events with MS.Ext.Logging)
#127
Comments
Quick and a little dirty workaround for now: _stream
.Select(FixEntryLoggingLevel)
.Select(LogEventReader.ReadFromJObject)
.Subscribe(...)
...
private static JObject FixEntryLoggingLevel(JObject entry)
{
if (!entry.TryGetValue("@l", out var levelToken))
{
return entry;
}
var value = levelToken?.Value<string>();
entry["@l"] = value switch
{
"Trace" => "Verbose",
"None" => "Verbose",
"Critical" => "Fatal",
_ => value
};
return entry;
} |
Hi @migajek; thanks for raising this.
The JSON transformation trick you're using here is probably the best way to go, for now; having it mentioned here will hopefully help anyone who hits this to work around it in the future 👍 |
Hi @nblumhardt, thanks - I understand LogEventReader belongs to Serilog - I'm not however suggesting the change to how reader works, rather what the API exposes :) I don't really understand why Seq provides different JSON representation for streaming API, comparing to fetching API. I suppose you have good reasons for that (be it performance or some internal technical considerations). However , if I may suggest - I'd consider providing the same I am assuming my usage scenario might be quite common - I'm combining past and incoming events together: fetch last N events for given filter, and subscribe to incoming events using the same filter. |
That makes sense - thanks @migajek. Does need some more thought at our end 👍 |
thanks :) sure, I'm fine with the workaround for now. Will keep an eye on this |
tl;dr:
When writing logs with
MS Ext Logging
and streaming them back to application as demonstrated in this library documentation, deserializing LogEvent usingLogEventReader.ReadFromJObject
fails with exception"Requested value 'Trace' was not found"
.long verson:
I'm using Seq as a logging storage for
Microsoft.Extensions.Logging
based app (usingSeq.Extensions.Logging
)Therefore the message levels stored in Seq are levels defined by
MS Ext Logging
.When streaming events back to the application, the documentation states the events should be deserialized into Serilog's
LogEvent
instances (usingLogEventReader.ReadFromJObject
) - unfortunately, the level is Serilog'sLogEventLevel
which is not compatible with MS Ext Logging levels (Trace vs Verbose and Critical vs Fatal)Technical aspects of the issue aside, I find it a little inconsistent:
SeqConnection.Events.Find / List
methods, we deal with Seq'sEventEntity
(which definesLevel
asstring
so we're fine here)SeqConnection.Events.Stream
method we deal with the Serilog'sLogEvent
json representation for some reasonThe text was updated successfully, but these errors were encountered: