Nodinite.Serilog.ServiceBusSink 2.0.16

There is a newer version of this package available.
See the version list below for details.
dotnet add package Nodinite.Serilog.ServiceBusSink --version 2.0.16                
NuGet\Install-Package Nodinite.Serilog.ServiceBusSink -Version 2.0.16                
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="Nodinite.Serilog.ServiceBusSink" Version="2.0.16" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Nodinite.Serilog.ServiceBusSink --version 2.0.16                
#r "nuget: Nodinite.Serilog.ServiceBusSink, 2.0.16"                
#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.
// Install Nodinite.Serilog.ServiceBusSink as a Cake Addin
#addin nuget:?package=Nodinite.Serilog.ServiceBusSink&version=2.0.16

// Install Nodinite.Serilog.ServiceBusSink as a Cake Tool
#tool nuget:?package=Nodinite.Serilog.ServiceBusSink&version=2.0.16                

Nodinite.Serilog.ServiceBusSink

Nodinite.Serilog.ServiceBusSink is a custom sink for Serilog designed to send a Nodinite logging events to a Microsoft Azure Service Bus Queue. Unlike the default Serilog sinks that write logs to a file, database, or other conventional destinations, this sink forwards the Nodinite log events to your Azure Service Bus Queue directly, which later picked up by the Nodinite Pickup service for further forwarding into Nodinite.

Features

  • Real-time logging: Events are sent to Microsoft Azure Service Bus Queue.
  • Seamless Integration: Works well with existing Serilog configurations.
  • Customizable: Supports additional custom fields to send along with the log events (CONTEXT PROPERTIES).

Documentation

Nodinite - Docs
Nodinite - Serilog Docs

Configuration

A Nodinite Log Event has mandatory and optional fields. Below is an example to get you started.

Field Example Value Comment
LogAgentValueId 503 Who (Log Agents) sent the data
EndPointName "Nodinite.Serilog.ServiceBusSink.Tests" Name of Endpoint transport
EndPointUri "Nodinite.Serilog.ServiceBusSink.Tests.Serilog" URI for Endpoint transport
EndPointDirection 0 Direction for Endpoint transport
EndPointTypeId 0 Type of Endpoint transport
OriginalMessageTypeName "Serilog.LogEvent" Message Type Name
ProcessingUser "Nodinite" Log Identity
ProcessName "My customer import process" Name of process
ProcessingMachineName "localhost" Name of server where log event originated
ProcessingModuleName "INT101-HelloHappyCustomers-Application" Name of module
ProcessingModuleType "FileImport" Type of module, exe, dll, service

Using code

Besides Serilog, the following nuget packages need to be installed

Using the following code below you can start logging events to Nodinite.

var connectionString = "{Your ServiceBus Connection String";
var queueName = "{Your ServiceBus Queue Name}";

var settings = new NodiniteLogEventSettings()
{
    LogAgentValueId = 503,
    EndPointDirection = 0,
    EndPointTypeId = 0,
    EndPointUri = "Nodinite.Serilog.ServiceBusSink.Tests.Serilog",
    EndPointName = "Nodinite.Serilog.ServiceBusSink.Tests",
    ProcessingUser = "NODINITE",
    ProcessName = "Nodinite.Serilog.ServiceBusSink.Tests",
    ProcessingMachineName = "NODINITE-DEV",
    ProcessingModuleName = "DOTNETCORE.TESTS",
    ProcessingModuleType = "DOTNETCORE.TESTPROJECT"
};

ILogger log = new LoggerConfiguration()
    .WriteTo.NodiniteServiceBusSink(connectionString, queueName, settings)
    .CreateLogger()
    .ForContext("ApplicationInterchangeId", $"CustomId-{Guid.NewGuid().ToString()}")
    .ForContext("CustomerId", 12)
    .ForContext("Body", JsonConvert.SerializeObject(new { Id = 1 }))
    .ForContext("OriginalMessageType", "TestMessage#1.0");

Using Appsettings.json (Preferred)

Besides Serilog, the following nuget packages need to be installed

Using the following code to initialize the logger in your application:

var configuration = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json")
    .Build();

Logger log = new LoggerConfiguration()
    .ReadFrom.Configuration(configuration)
    .CreateLogger();

And putting the following into your appsettings.json:

{
  "Serilog": {
    "Using": [ "Nodinite.Serilog.ServiceBusSink" ],
    "WriteTo": [
      {
        "Name": "NodiniteServiceBusSink",
        "Args": {
          "ConnectionString": "",
          "QueueName":  "",
          "Settings": {
            "LogAgentValueId": 503,
            "EndPointName": "Nodinite.Serilog.ServiceBusSink.Tests",
            "EndPointUri": "Nodinite.Serilog.ServiceBusSink.Tests.Serilog",
            "EndPointDirection": 0,
            "EndPointTypeId": 0,
            "OriginalMessageTypeName": "Serilog.LogEvent",
            "ProcessingUser": "NODINITE",
            "ProcessName": "Nodinite.Serilog.ServiceBusSink.Tests",
            "ProcessingMachineName": "NODINITE-DEV",
            "ProcessingModuleName": "DOTNETCORE.TESTS",
            "ProcessingModuleType": "DOTNETCORE.TESTPROJECT"
          }
        }
      }
    ]
  }
}

Logging Context Properties

ILogger log = new LoggerConfiguration()
    .WriteTo.NodiniteServiceBusSink(connectionString, queueName, settings)
    .CreateLogger()
    .ForContext("CorrelationId", Guid.NewGuid())
    .ForContext("CustomerId", 12);

log.Information("Customer '12' has been imported.");

The Serilog sink will automatically loop over all context properties you have defined in your code and log them as part of your event to Nodinite.

Support

For bugs, feature requests, or other concerns, please contact us at support@nodinite.com.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
2.0.18 69 10/25/2024
2.0.17 85 10/10/2024
2.0.16 453 9/11/2024
2.0.15 146 8/23/2024
2.0.14 91 7/26/2024
2.0.12 92 7/10/2024
2.0.11 130 6/12/2024
2.0.9 121 5/15/2024
2.0.8 112 4/10/2024
2.0.7 133 3/13/2024
2.0.6 140 2/14/2024
2.0.4 148 1/10/2024
2.0.2 326 11/15/2023
2.0.1 97 11/6/2023
2.0.0 9,058 2/13/2023
1.4.0 254 2/9/2023
1.3.0 2,691 2/21/2022
1.2.0 465 2/14/2022
1.0.6 2,025 9/7/2020
1.0.5 888 5/4/2020
1.0.4 1,939 2/28/2020
1.0.3 570 10/10/2019
1.0.2 579 10/10/2019
1.0.1 536 10/10/2019