access to event data in Emit method

241 views
Skip to first unread message

Alan Lu

unread,
Apr 3, 2017, 4:45:47 PM4/3/17
to Serilog
Hi,
What is the best approach to access the LogEvent data within Emit method when creating a new sink? For example, if i need to process the LogEvent and write it to a number of database columns of various datatypes not just strings, I currently get the values from the "Properties" collection, then cover string values to desired data types. The issue I see with this approach is that there is an unnecessary conversion from text to types needs to happen for every message being logged. Any suggestions? 
Thanks,
Alan

nblum...@nblumhardt.com

unread,
Apr 3, 2017, 5:02:24 PM4/3/17
to Serilog
Hi Alan,

You'll find the `LogEventPropertyValue` objects from `Properties` can be cast down to `ScalarValue` and a few other related types. `ScalarValue.Value` is the data you're looking for.

HTH!
Nick
Reply all
Reply to author
Forward
0 new messages