Package Name | NuGet | Description |
---|---|---|
NLog.Extensions.AzureQueueStorage | Azure Queue Storage |
<extensions>
<add assembly="NLog.Extensions.AzureQueueStorage" />
</extensions>
<targets>
<target xsi:type="AzureQueueStorage"
name="String"
layout="Layout"
connectionString="Layout"
queueName="Layout">
<metadata name="mymeta" layout="mymetavalue" /> <!-- Multiple allowed -->
</target>
</targets>
name - Name of the target.
layout - Queue Message Text to be rendered. Layout Required.
queueName - QueueName. Layout
connectionString - Azure storage connection string. Ex. UseDevelopmentStorage=true;
serviceUri - Alternative to ConnectionString, where Managed Identiy is acquired from DefaultAzureCredential for User delegation SAS.
clientIdentity - Alternative to ConnectionString. Used together with ServiceUri. Input for DefaultAzureCredential as ManagedIdentityClientId.
resourceIdentity - Alternative to ConnectionString. Used together with ServiceUri. Input for DefaultAzureCredential as ManagedIdentityResourceId.
tenantIdentity - Alternative to ConnectionString. Used together with ServiceUri. Input for DefaultAzureCredential.
sharedAccessSignature - Alternative to ConnectionString. Used together with ServiceUri. Input for AzureSasCredential
accountName - Alternative to ConnectionString. Used together with ServiceUri. Input for StorageSharedKeyCredential-AccountName
accessKey - Alternative to ConnectionString. Used together with ServiceUri. Input for StorageSharedKeyCredential-AccessKey
timeToLiveSeconds - Default Time-To-Live (TTL) for Queue messages in seconds (Optional)
timeToLiveDays - Default Time-To-Live (TTL) for Queue messages in days (Optional)
batchSize - Number of EventData items to send in a single batch (Default=100)
taskDelayMilliseconds - Artificial delay before sending to optimize for batching (Default=200 ms)
queueLimit - Number of pending LogEvents to have in memory queue, that are waiting to be sent (Default=10000)
overflowAction - Action to take when reaching limit of in memory queue (Default=Discard)
taskTimeoutSeconds - How many seconds a Task is allowed to run before it is cancelled (Default 150 secs)
retryDelayMilliseconds - How many milliseconds to wait before next retry (Default 500ms, and will be doubled on each retry).
retryCount - How many attempts to retry the same Task, before it is aborted (Default 0)
When using ServiceUri
(Instead of ConnectionString), then DefaultAzureCredential
is used for Azure Identity which supports environment variables:
AZURE_CLIENT_ID
- For ManagedIdentityClientId / WorkloadIdentityClientIdAZURE_TENANT_ID
- For TenantId
See also: Set up Your Environment for Authentication
NLog Layout makes it possible to retrieve settings from many locations.
connectionString="${configsetting:ConnectionStrings.AzureQueue}"
- Example appsettings.json on .NetCore:
{
"ConnectionStrings": {
"AzureQueue": "UseDevelopmentStorage=true;"
}
}
connectionString="${appsetting:ConnectionStrings.AzureQueue}"
- Example app.config on .NetFramework:
<configuration>
<connectionStrings>
<add name="AzureQueue" connectionString="UseDevelopmentStorage=true;"/>
</connectionStrings>
</configuration>
connectionString="${environment:AZURE_STORAGE_CONNECTION_STRING}"
connectionString="${gdc:AzureQueueConnectionString}"
- Example code for setting GDC-value:
NLog.GlobalDiagnosticsContext.Set("AzureQueueConnectionString", "UseDevelopmentStorage=true;");