Package - Serilog.Sinks.AzureQueueStoragev2 | .NET Standard 2.0
Package to write to an Azure Queue in an Azure Storage Account. This package replaces the deprecated and no longer maintained library of Serilog.Sinks.AzureQueueStorage.
It now uses the Azure.Storage.Queues which replaces the deprecated WindowsAzure.Storage, which was used in the previous package.
Getting started guide with Azure Queues.
To log using this sink from an Azure App Service or Function:
- Enable System Assigned Managed Identity from the Identity section in the Azure Portal
- On the storage account give the App the Role: Storage Queue Data Message Sender
- Configure the sink with the URL for the storage account queue; this the Sink will use the AzureDefaultCredentials for access to the queue.
var log = new LoggerConfiguration().WriteTo
.AzureQueueStorage("azureStorageAccountConnectionString", "azureQueueName")
.CreateLogger();
Or to use DefaultAzureCredentials:
var log = new LoggerConfiguration().WriteTo
.AzureQueueStorage(new Uri("<storage_account_url>/<quene_name>"))
.CreateLogger();
Optional parameter of restrictedToMinimumLevel which is an LogEventLevel
enum that defines the minimum level of logging. By default this is set to 0 (verbose). You can override like so:
var log = new LoggerConfiguration().WriteTo
.AzureQueueStorage("azureStorageAccountConnectionString", "azureQueueName", LogEventLevel.Information)
.CreateLogger();
var log = new LoggerConfiguration().WriteTo
.AzureQueueStorage(new Uri("<storage_account_url>/<quene_name>"), LogEventLevel.Information)
.CreateLogger();