Serilog.Sinks.InsightIdr 1.1.1

dotnet add package Serilog.Sinks.InsightIdr --version 1.1.1
                    
NuGet\Install-Package Serilog.Sinks.InsightIdr -Version 1.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Serilog.Sinks.InsightIdr" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Serilog.Sinks.InsightIdr" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Serilog.Sinks.InsightIdr" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Serilog.Sinks.InsightIdr --version 1.1.1
                    
#r "nuget: Serilog.Sinks.InsightIdr, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Serilog.Sinks.InsightIdr@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Serilog.Sinks.InsightIdr&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Serilog.Sinks.InsightIdr&version=1.1.1
                    
Install as a Cake Tool

<h1 align="center">Serilog Sinks: insightIDR (InsightOps)</h1>

<div align="center"> A sink for Serilog that writes events to insightIDR (InsightOps) by Rapid7. </div>

<br />

A Serilog sink that writes log events to insightIDR (InsightOps) via TCP or HTTPS.

This sink is also configured for the most common scenario's - an easy way to get started for most people. As such some advanced features are (by design) left out of this sink.

<hr/>

Table of Contents

<hr/>

Getting started (simple, text-based logging)

To use the console sink, first install the NuGet package:

Install-Package Serilog.Sinks.InsightIDR

Next, define you insightIDR (InsightOps) account settings:

var settings = new InsightIdrSinkSettings
{
    Region = "<to fill in by you>", // au, eu, jp or us
    Token = "<to fill in by you>", // Guid, taken from your insightIDR (InsightOps) log account
    UseSsl = false, // or True for sending via HTTPS. Make sure you can handle TLS1.2 (or newer)
    Debug = false // or True to see low level R7 Insight ops debug messages in the console (this is helpful actually!)

    // Optional settings people rarely use. You can ignore these, unless you know what you're doing:
    // (and these are the defaults)
    IsUsingDataHub = false, // Set to true to use custom DataHub instance instead of Logentries service.
    DataHubAddress = null, // DataHub server address
    DataHubPort = 0, // DataHub server port
    LogHostname = null, // Set to true to send HostName alongside with the log message
    HostName = null, // User-defined host name. If empty the library will try to obtain it automatically
    LogID = null // Log ID
};

Then enable the sink using WriteTo.InsightIDR():

Log.Logger = new LoggerConfiguration()
    .WriteTo.InsightIDR(settings)
    .CreateLogger();

And now log something. Here's an example of some semantic logging:

var position = new { Latitude = 25, Longitude = 134 };
var elapsedMs = 34;
log.Information("Processed {@Position} in {Elapsed:000} ms.", position, elapsedMs);

Log events will look like this at insightIDR (InsightOps):

13 Nov 2019 00:59:47.645 Processed { Latitude: 25, Longitude: 134 } in 034 ms.

Log view

alternate text is missing from this package README image

Table view

alternate text is missing from this package README image

More advanced getting started (loading settings via configuration file)

Probably the best way to load the configuration settings is via your appSettings.config file(s).

Here's a lovely example:

  1. ⚠ Make sure you install the Serilog.Sinks.InsightIDR nuget package, otherwise the Serilog won't be able to load the configuration settings.
  2. Add the relevant section to your appSettings.config file(s)
    • Using section
    • WriteTo section
    • Name and Args key/values.

image

<details> <summary>Example appSettings.json code (copy/paste friendly)</summary>

{
    "Serilog": {
        "Using": [ "Serilog.Sinks.InsightIDR" ],
        "MinimumLevel": {
            "Default": "Debug",
            "Override": {
                "System": "Debug",
                "Microsoft": "Debug"
            }
        },
        "WriteTo": [
            {
                "Name": "Console"
            },
            {
                "Name": "InsightOps",
                "Args": {
                    "Token": "<to be manually set>",
                    "Region": "eu",
                    "UseSsl": "true"
                }
            }
        ]
    }
}

</details>

Structured Logging

To get structured logging with InsightIDR (insightOps), we will need to send the data (over the wire) as JSON.
To do that, we need to do the following:

Log.Logger = new LoggerConfiguration()
    // 🤘🏻 Notice how we've defined the JSON formatter! 🤘🏻
    .WriteTo.InsightIDR(settings, new RenderedCompactJsonFormatter())
    .CreateLogger();

and this will now send the data up to insightOps as Structed Logging:

Log view

image

Table View

image

For the record, there are the types of JSON data formats you can use:

  • JsonFormatter()
  • CompactJsonFormatter() [This has no @m "message" property. Only the @mt "message template"]
  • RenderedCompactJsonFormatter() [This has an @m message property, plus other values]

Structured Logging (Advanced) : Settings via configuration file

Here's an example section of loading the settings via the appSettings.config file:

Note the Formatter arg.

{
    "Serilog": {
        "Using": [ "Serilog.Sinks.InsightIDR" ],
        "MinimumLevel": {
            "Default": "Debug",
            "Override": {
                "System": "Debug",
                "Microsoft": "Debug"
            }
        },
        "WriteTo": [
            {
                "Name": "Console"
            },
            {
                "Name": "InsightIDR",
                "Args": {
                    "Token": "<to be manually set>",
                    "Region": "eu",
                    "UseSsl": "true",
                    "Formatter": "Serilog.Formatting.Compact.RenderedCompactJsonFormatter, Serilog.Formatting.Compact"
                }
            }
        ]
    }
}

This library provides a sink for InsightIdr for Serilog. Serilog is copyright © 2019 Serilog Contributors - Provided under the Apache License, Version 2.0. For more detailed explanation of these, this is a blog post from the Serilog author. See also: Serilog Documentation

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 206 8/5/2026
1.0.3 595 5/21/2026
1.0.1 104 5/19/2026