Runpath.Extensions.Logging.AzureEventHubs
1.0.0
Prefix Reserved
See the version list below for details.
dotnet add package Runpath.Extensions.Logging.AzureEventHubs --version 1.0.0
NuGet\Install-Package Runpath.Extensions.Logging.AzureEventHubs -Version 1.0.0
<PackageReference Include="Runpath.Extensions.Logging.AzureEventHubs" Version="1.0.0" />
paket add Runpath.Extensions.Logging.AzureEventHubs --version 1.0.0
#r "nuget: Runpath.Extensions.Logging.AzureEventHubs, 1.0.0"
// Install Runpath.Extensions.Logging.AzureEventHubs as a Cake Addin #addin nuget:?package=Runpath.Extensions.Logging.AzureEventHubs&version=1.0.0 // Install Runpath.Extensions.Logging.AzureEventHubs as a Cake Tool #tool nuget:?package=Runpath.Extensions.Logging.AzureEventHubs&version=1.0.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 | Versions 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. |
-
.NETStandard 2.0
- Microsoft.Azure.EventHubs (>= 3.0.0)
- Microsoft.Extensions.Logging (>= 2.1.1)
- Microsoft.Extensions.Logging.Configuration (>= 2.1.1)
- System.Threading.Channels (>= 4.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.