Plugin to log Service bus messages
This is an add-in for Microsoft.Azure.ServiceBus client
Allow to log messages before being sent by tracing or saving in an Azure Storage Account Table.
To Install from the Nuget Package Manager Console
PM > Install-Package ServiceBus.LoggingPlugin
NET CLI - dotnet add package ServiceBus.LoggingPlugin
paket paket add ServiceBus.LoggingPlugin
Available here https://www.nuget.org/packages/ServiceBus.LoggingPlugin
Configuration and registration
queueClient = new QueueClient(ServiceBusConnectionString, QueueName);
queueClient.RegisteredPlugins.Add(new LoggingPlugin(configurations =>
{
configurations.LoggingType = LoggingType.Trace;
}));
Configuration and registration
queueClient = new QueueClient(ServiceBusConnectionString, QueueName);
queueClient.RegisteredPlugins.Add(new LoggingPlugin(configurations =>
{
configurations.LoggingType = LoggingType.StorageTable;
configurations.SendInBackground = true;
configurations.ConfigureStorageAccount(information =>
{
information.ConnectionString = "Insert Storage Connection string";
});
}));
Optional Configurations
Custom Partition key
Custom storage table name
configurations.ConfigureStorageAccount(information =>
{
information.ConnectionString = "Insert Storage Connection string";
information.PartitionKey = "YourPartitionKey";
information.TableName = "YourTableName";
});
Configuration and registration
queueClient = new QueueClient(ServiceBusConnectionString, QueueName);
queueClient.RegisteredPlugins.Add(new LoggingPlugin(configurations =>
{
configurations.LoggingType = LoggingType.None;
configurations.Log = message =>
{
// you can handle manually the message here
var m1 = message;
};
}));
Configuration and registration
public class CustomLoggingService : ILoggingService
{
public void Dispose()
{
}
public bool Disposed { get; set; }
public Task LogSentMessage(Message message)
{
// implement your logic here
}
public void SetConfigurations(ILogginConfigurations configurations)
{
}
}
queueClient = new QueueClient(ServiceBusConnectionString, QueueName);
queueClient.RegisterLoggingService(new CustomLoggingService());
Created by Mariana Alemanno
Made with ❤ in DGENIX