Seq Email Body Tempate

73 views
Skip to first unread message

Wayne Brantley

unread,
Nov 12, 2014, 2:07:55 PM11/12/14
to get...@googlegroups.com
Using the email app for Seq, https://www.nuget.org/packages/Seq.App.Email/  how do we create a custom body template for the email?
I would simply like to:
1)  Use HTML in the email.
2)  The email is going to only be for exceptions, so I would like the actual exception message at the top and bold, etc.
4)  Output all other items and the call stack.


I cannot achieve #4, looking at the default template - it cannot be achieved - you are dynamically writing out the property items by what exists!  I have no way to do 'foreach' loop in the template that I know of, etc...



string FormatDefaultBody(Event<LogEventData> evt)
{
var body = new StringBuilder();
body.Append("{{@Timestamp}} [{{@Level}}] {{@RenderedMessage}}");
if (evt.Data.Properties != null)
{
body.AppendLine();
foreach (var property in evt.Data.Properties.OrderBy(p => p.Key))
{
body.AppendFormat(" {0} = {{{{{1}}}}}", property.Key, property.Key);
body.AppendLine();
}
}
if (evt.Data.Exception != null)
{
body.AppendLine();
body.Append("{{@Exception}}");
}
return FormatTemplate(body.ToString(), evt);
}

nblum...@nblumhardt.com

unread,
Nov 12, 2014, 5:13:10 PM11/12/14
to get...@googlegroups.com
Hi Wayne!

Looks like you're already close to a solution - the trick's to just grab the source from: https://github.com/continuousit/seq-apps/tree/master/src/Seq.App.Email (it's Apache 2 licensed) and publish the resulting package to an internal NuGet feed that you can add to Seq under "Feeds".

This will give you ultimate flexibility without us having to add complexity to the default app.

Should be very straightforwards, please let me know if I can help out at all.

Best Regards,
Nick

Wayne Brantley

unread,
Nov 12, 2014, 6:11:08 PM11/12/14
to get...@googlegroups.com
Well, there is very little use in having this 'body template' if I cannot output all the properties?
Seems like anyone that wants to do anything will have to modify source code?

I should be able to create an HTML Template that does exactly what your default template does...but I cannot, because there is no way to loop through all the properties, etc.   

As it stands, seems like I should not have to create my own add in, just to get the output of the email to look differently.  I guess to not do that I would have to know every property of the object and have them manually specified in the email?

Reply all
Reply to author
Forward
0 new messages