Multi-line events

31 views
Skip to first unread message

Kevin Ashton

unread,
Nov 10, 2014, 3:15:53 AM11/10/14
to get...@googlegroups.com
Hi,

I was wondering how you would handle events that have hard line-breaks in them? (I currently have modified the seq.js to handle it), but I am wondering if this might be a valid feature request?

I think to explain it better I need should give my use-case.

I have a system that works similar to Elmah where the events are logged to Seq, and I want to display the items something like:

Error: {Exception Message}
Error Type: {Exception Type}
Stack: {Exception Stack Trace}
Cookies: {Cookies Collection}
Form Variables: {Form Variables Collection}
Server Variables: {Server variables Collection}
etc.


nblum...@nblumhardt.com

unread,
Nov 10, 2014, 3:58:04 PM11/10/14
to get...@googlegroups.com
Hi Kevin!

Presently the best way to tackle this with Seq is to use a property for each of these items. The display for Exception already shows the multi-line stacktrace, messages, inner exceptions and so-on; attaching the others to the events individually should round this out.

To do this you might use the following type of statement in Serilog:

Log.ForContext(new[] {
  new PropertyEnricher("Cookies", cookies, true),
  new PropertyEnricher("FormVariables", formVariables, true),
  new PropertyEnricher("ServerVariables", serverVariables, true)
}).Error(ex, "An error occurred");

(The additional 'true' parameter will cause the values to be serialized rather than ToString()ed.

Hope this helps, let us know how you go!

Cheers,
Nick
Reply all
Reply to author
Forward
0 new messages