The Wayback Machine - https://web.archive.org/web/20210916084806/https://github.com/JDetmar/NLog.Extensions.AzureStorage
Skip to content
master
Switch branches/tags
Code

NLog Targets for Azure Storage AppVeyor

logo

Package Name NuGet Description Documentation
NLog.Extensions.AzureBlobStorage NuGet Azure Blob Storage
NLog.Extensions.AzureCosmosTable NuGet Azure Table Storage or Azure CosmosDb Tables
NLog.Extensions.AzureDataTables NuGet Azure Table Storage or Azure CosmosDb Tables
NLog.Extensions.AzureEventHub NuGet Azure EventHubs
NLog.Extensions.AzureQueueStorage NuGet Azure Queue Storage
NLog.Extensions.AzureServiceBus NuGet Azure Service Bus
NLog.Extensions.AzureAccessToken NuGet Azure App Authentication Access Token for Managed Identity

Before all NLog targets was bundled into a single nuget-package called NLog.Extensions.AzureStorage. But Microsoft decided to discontinue WindowsAzure.Storage and split into multiple parts.

Sample Configuration

<extensions>
  <add assembly="NLog.Extensions.AzureBlobStorage" /> 
  <add assembly="NLog.Extensions.AzureDataTables" /> 
  <add assembly="NLog.Extensions.AzureQueueStorage" /> 
  <add assembly="NLog.Extensions.AzureEventHub" /> 
  <add assembly="NLog.Extensions.AzureServiceBus" /> 
  <add assembly="NLog.Extensions.AzureAccessToken" /> 
</extensions>

<targets async="true">
    <target type="AzureBlobStorage"
            name="Azure"
            layout="${longdate:universalTime=true} ${level:uppercase=true} - ${logger}: ${message} ${exception:format=tostring}"
            connectionString="DefaultEndpointsProtocol=https;AccountName=##accountName##;AccountKey=##accountKey##;EndpointSuffix=core.windows.net"
            container="${machinename}"
            blobName="${logger}/${date:universalTime=true:format=yy-MM-dd}/${date:universalTime=true:format=HH}.log">
                <metadata name="mymeta" layout="mymetavalue" />   <!-- Multiple allowed -->
    </target>
    <target type="AzureDataTables"
            name="AzureTable"
            connectionString="DefaultEndpointsProtocol=http;AccountName=##accountName##;AccountKey=##accountKey##;"
            layout="${message} ${exception:format=tostring}"
            tableName="NlogTable" />
    <target type="AzureQueueStorage"
            name="AzureQueue"
            connectionString="UseDevelopmentStorage=true;"
            layout="${longdate:universalTime=true} ${level:uppercase=true} - ${logger}: ${message} ${exception:format=tostring}"
            queueName="NlogQueue">
                <metadata name="mymeta" layout="mymetavalue" />   <!-- Multiple allowed -->
    </target>
    <target type="AzureEventHub"
            name="AzureEventHub"
            connectionString="Endpoint=sb://test.servicebus.windows.net/;SharedAccessKeyName=NLog;SharedAccessKey=EventHub"
            layout="${longdate:universalTime=true} ${level:uppercase=true} - ${logger}: ${message} ${exception:format=tostring}"
            eventHubName="NlogHub"
            PartitionKey="0">
                <userproperty name="exceptiontype" layout="${exception:format=type}" />   <!-- Multiple allowed -->
    </target>
    <target type="AzureServiceBus"
            name="AzureServiceBus"
            connectionString="Endpoint=sb://test.servicebus.windows.net/;SharedAccessKeyName=NLog;SharedAccessKey=ServiceBus"
            layout="${longdate:universalTime=true} ${level:uppercase=true} - ${logger}: ${message} ${exception:format=tostring}"
            label="Message from NLog"
            topiceName="NLogTopic">
                <userproperty name="exceptiontype" layout="${exception:format=type}" />   <!-- Multiple allowed -->
    </target>
</targets>

License

FOSSA Status