Skip to content

Plugin to log Service bus message in an storage account

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
COPYING.txt
Notifications You must be signed in to change notification settings

davidrevoledo/ServiceBus.LoggingPlugin

Repository files navigation

Service bus Logging Plugin

ServiceBus.LoggingPlugin

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.

Build status CodeFactor NuGet NuGet License: MIT

Nuget package

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

Examples

Use Tracing method

Configuration and registration

      queueClient = new QueueClient(ServiceBusConnectionString, QueueName);

      queueClient.RegisteredPlugins.Add(new LoggingPlugin(configurations =>
      {
          configurations.LoggingType = LoggingType.Trace;
      }));

Using Storage Account Mode

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";
                });

Simple Log Method

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;
          };
      }));

Use Custom LoggerService

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());

Icon

Created by Mariana Alemanno

Made with ❤ in DGENIX

About

Plugin to log Service bus message in an storage account

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
COPYING.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages