Runpath.Extensions.Logging.AzureEventHubs 1.1.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Runpath.Extensions.Logging.AzureEventHubs --version 1.1.0
NuGet\Install-Package Runpath.Extensions.Logging.AzureEventHubs -Version 1.1.0
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="Runpath.Extensions.Logging.AzureEventHubs" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Runpath.Extensions.Logging.AzureEventHubs --version 1.1.0
#r "nuget: Runpath.Extensions.Logging.AzureEventHubs, 1.1.0"
#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 Runpath.Extensions.Logging.AzureEventHubs as a Cake Addin
#addin nuget:?package=Runpath.Extensions.Logging.AzureEventHubs&version=1.1.0

// Install Runpath.Extensions.Logging.AzureEventHubs as a Cake Tool
#tool nuget:?package=Runpath.Extensions.Logging.AzureEventHubs&version=1.1.0

Runpath.Extensions.Logging.AzureEventHubs

Azure Event Hubs logger provider implementation for Microsoft.Extensions.Logging.

Getting started

Grab the package from NuGet, which will install all dependencies.

Install-Package Runpath.Extensions.Logging.AzureEventHubs

Usage

Extensive documentation for Microsoft.Extensions.Logging is available here and should cover most general aspects of this library.

Once your Azure Event Hubs resource is configured in Azure, you can then add its details to your configuration. The options expose 4 values that you can later use:

{
  "Logging": {
    "AzureEventHubs": {
      "Endpoint": "sb://example.servicebus.windows.net",
      "EntityPath": "my-hub",
      "SharedAccessKeyName": "my-key",
      "SharedAccessKey": "..."
    }
  }
}

Add this logger provider to your logging builder, supplying a delegate that creates an EventHubClient to your specifications, for example:

var services = new ServiceCollection();

services.AddLogging(builder => builder.AddAzureEventHubs(options =>
  options.TryGetConnectionString(out string connectionString)
    ? EventHubClient.CreateFromConnectionString(connectionString)
    : EventHubClient.CreateWithManagedServiceIdentity(options.Endpoint, options.EntityPath);
));

IAzureEventHubsLoggerFormatter

The formatting of event data is controlled by an instance of this interface. A default implementation is supplied out of the box, which formats events as JSON:

{
    "Timestamp": "2019-07-11T08:53:37.772Z",
    "LogLevel": "Information",
    "Category": "MyApplication",
    "EventId": 0,
    "Message": "Application started.",
    "Exception": null
}

To implement your own custom format, create your own implementation of IAzureEventHubsLoggerFormatter and replace the default instance in your service collection.

Custom implementations will have access to external scope data, provided by IExternalScopeProvider. To consume this, use the ForEachScope method exposed by IAzureEventHubsLoggerFormatter.

IAzureEventHubsLoggerProcessor

The processing of event data is controlled by an instance of this interface. A default implementation is supplied that implements a queue, offloads work to a background thread, and sends event data using batches.

The options expose 2 (optional) values to customise the thresholds and queuing logic of the default processor:

{
  "Logging": {
    "AzureEventHubs": {
      "QueueDepth": 1024,
      "QueueMode": "DropOldest"
    }
  }
}

QueueDepth must be a positive integer, and defaults to 1024. QueueMode can accept one of the values of BoundedChannelFullMode, and defaults to DropOldest.

To implement your own custom processing logic, create your own implementation of IAzureEventHubsLoggerProcessor and replace the default instance in your service collection.

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
1.2.0 11,144 4/12/2021
1.1.0 19,719 12/6/2019
1.0.1 1,222 11/4/2019
1.0.0 1,758 8/2/2019