Documentation
DocumentationDiscussions
Documentation
These docs are for v4. Click to read the latest docs for v2024.3.

Writing Seq Apps

Seq apps are simple C# classes packaged into standard NuGet .nupkg files.

πŸ‘

Full Source Code

The Seq.Apps project on GitHub contains heaps of examples to get you started.

The example below shows a snippet from the Formatted Email app, with full source available on GitHub.

Creating a new App Project

Apps are implemented in regular .NET 4.5 class libraries.

1394

Once the project has been created, install the Seq.Apps NuGet package.

PM> Install-Package Seq.Apps

Declaring the Reactor Class

The logic of the app lives in a subclass of Reactor.

[SeqApp("Formatted Email",
    Description = "Uses a provided template to send events as formatted email.")]
public class EmailReactor : Reactor, ISubscribeTo<LogEventData>
{
    [SeqAppSetting(
        DisplayName = "From address",
        HelpText = "The account from which the email is being sent.")]
    public string From { get; set; }

(Complete example…)

Writing the On() method

The rest of the plugin is just as straight-forward: a few more fields, an On method, and some formatting helpers:

public void On(Event<LogEventData> evt)
{
    var body = string.IsNullOrWhiteSpace(BodyTemplate) ?
        FormatDefaultBody(evt) :
        FormatTemplate(BodyTemplate, evt);
 
    var subject = FormatTemplate(SubjectTemplate, evt);
 
    var client = new SmtpClient(Host, Port ?? 25);
    if (!string.IsNullOrWhiteSpace(Username))
        client.Credentials = new NetworkCredential(Username, Password);
 
    client.Send(From, To, subject, body);
}

Packaging

To package an app without third-party libraries, a simple nuget pack on the .csproj file is adequate.

If your app uses other libraries, these must be included as files in the package rather than specified as dependencies, because at run-time Seq will not load files from other packages.

🚧

Don't package the Seq.Apps.dll or Serilog.dll assemblies into your app. They're loaded automatically by the Seq server.

Looking at existing samples is the best way to get started, but the discussion forum is also a good place to ask for help.