From 82ed25c574cd71284233a94e23404764685a1649 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Mon, 12 Oct 2020 14:36:01 +1000 Subject: [PATCH 01/10] Dev version bump [skip ci] --- .../Serilog.Sinks.AzureEventHub.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj index 0d1a150..3a3b35b 100644 --- a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj +++ b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj @@ -1,7 +1,7 @@ Write Serilog events to Azure Event Hub - 5.0.0 + 5.0.1 Serilog Contributors netstandard2.0;net461;net451 true From cbe81c3ceb1c4fea2087a005b6a9bd2f9ee87faa Mon Sep 17 00:00:00 2001 From: Alastair Crabtree Date: Mon, 15 Feb 2021 17:19:06 +0000 Subject: [PATCH 02/10] Update Microsoft.Azure.EventHubs 1.0.3 to 4.3.1 Updates the main dependency to the latest version of the event hub SDK. Without this change the sink will not work on .net5 as the sink throws a silent exception. v1 of the event hub SDK is 4 years old so probably lots of other improvements, including better support AMQP --- .../Serilog.Sinks.AzureEventHub.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj index 3a3b35b..3ed557a 100644 --- a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj +++ b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj @@ -24,7 +24,7 @@ - + From c27faf20959204a2789df924a236c03a89960487 Mon Sep 17 00:00:00 2001 From: Alastair Crabtree Date: Fri, 26 Mar 2021 10:13:25 +0000 Subject: [PATCH 03/10] task: remove 451 support, rev version to 6.0 --- .../Serilog.Sinks.AzureEventHub.csproj | 9 ++++----- .../Serilog.Sinks.AzureEventHub.nuspec | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj index 3ed557a..88d3c34 100644 --- a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj +++ b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj @@ -1,16 +1,16 @@ Write Serilog events to Azure Event Hub - 5.0.1 + 6.0.0 Serilog Contributors - netstandard2.0;net461;net451 + netstandard2.0;net461 true Serilog.Sinks.AzureEventHub ../../assets/Serilog.snk true true Serilog.Sinks.AzureEventHub - serilog;;azure;eventhub + serilog;azure;eventhub http://serilog.net/images/serilog-sink-nuget.png http://serilog.net http://www.apache.org/licenses/LICENSE-2.0 @@ -22,9 +22,8 @@ true - - + diff --git a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.nuspec b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.nuspec index aecc655..d375578 100644 --- a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.nuspec +++ b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.nuspec @@ -14,7 +14,7 @@ - + From d4da641b58dc1a67a1b2b9453393aa9105f0bb6e Mon Sep 17 00:00:00 2001 From: Alastair Crabtree Date: Fri, 26 Mar 2021 10:57:15 +0000 Subject: [PATCH 04/10] bug: Fix build failure for 461 --- .../Serilog.Sinks.AzureEventHub.csproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj index 88d3c34..fcb5f77 100644 --- a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj +++ b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj @@ -19,8 +19,6 @@ false Serilog true - - true From a2a8d88e917a1c2f99f5b228d479e786335bbc90 Mon Sep 17 00:00:00 2001 From: Alastair Crabtree Date: Fri, 26 Mar 2021 10:57:46 +0000 Subject: [PATCH 05/10] task: fix nuget warnings and errors --- .../Serilog.Sinks.AzureEventHub.csproj | 4 ++-- .../Serilog.Sinks.AzureEventHub.nuspec | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj index fcb5f77..a122565 100644 --- a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj +++ b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj @@ -11,15 +11,15 @@ true Serilog.Sinks.AzureEventHub serilog;azure;eventhub - http://serilog.net/images/serilog-sink-nuget.png http://serilog.net - http://www.apache.org/licenses/LICENSE-2.0 + Apache-2.0 https://github.com/serilog/serilog-sinks-azureeventhub git false Serilog true + diff --git a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.nuspec b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.nuspec index d375578..a1e3e27 100644 --- a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.nuspec +++ b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.nuspec @@ -7,8 +7,8 @@ Serilog event sink that writes to Azure Event Hubs. en-US http://serilog.net - http://www.apache.org/licenses/LICENSE-2.0 - http://serilog.net/images/serilog-sink-nuget.png + Apache-2.0 + http://serilog.net/images/serilog-sink-nuget.png serilog logging azure From 7bc1e602a8b50f17b2f7fe31084f560a4c2a0b23 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Sat, 27 Mar 2021 09:12:34 +1000 Subject: [PATCH 06/10] Publishing key update --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 66579b4..900b58f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,7 +12,7 @@ artifacts: deploy: - provider: NuGet api_key: - secure: M3xezaJaXj9AKyEhceQI9XRCP7/tG1YLOGM6x9tBAVuhE45IP9leFegUDtu632FD + secure: jWslQvxA4UMn98aYnsFDBfl8A2vAXUjtmmPZNxZnbJvMW/JV55iQ1fRcqD9B70sK skip_symbols: true on: branch: /^(master|dev)$/ From ce72d12e72b5a91b5fdf29d71ccfcc658274071c Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Fri, 9 Apr 2021 08:40:56 +1000 Subject: [PATCH 07/10] Another attempt at NuGet publishing --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 900b58f..b00a0cb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,7 +12,7 @@ artifacts: deploy: - provider: NuGet api_key: - secure: jWslQvxA4UMn98aYnsFDBfl8A2vAXUjtmmPZNxZnbJvMW/JV55iQ1fRcqD9B70sK + secure: K6TcIFIyxBcDuZ5DL7bJC+fGwDo458q0SDh+ybLujGTddA/voxg2FMUtJQ7rTEbt skip_symbols: true on: branch: /^(master|dev)$/ From 2f78f69888f0a574825edc7b5a0e3f7ecc718791 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Fri, 9 Apr 2021 08:46:45 +1000 Subject: [PATCH 08/10] Update appveyor.yml --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index b00a0cb..e5b0bf5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,7 +12,7 @@ artifacts: deploy: - provider: NuGet api_key: - secure: K6TcIFIyxBcDuZ5DL7bJC+fGwDo458q0SDh+ybLujGTddA/voxg2FMUtJQ7rTEbt + secure: pvGk80Hl+hnqiV0ucxBI2ZkYUlR6l7TrGZek37OCFh9Fro4BOhEBI2+UMkDwtgjt skip_symbols: true on: branch: /^(master|dev)$/ From a4bfd44d5a5c440993617b1f930d67e2a5129533 Mon Sep 17 00:00:00 2001 From: Michael McKechney Date: Fri, 21 May 2021 16:28:50 -0400 Subject: [PATCH 09/10] Updating the Auzre SDK to the new Azure.Messaging.EventHubs (https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.EventHubs_5.4.1/sdk/eventhub/Azure.Messaging.EventHubs) --- ...gerConfigurationAzureEventHubExtensions.cs | 19 ++----- ...gerConfigurationAzureEventHubExtensions.cs | 19 ++----- .../Serilog.Sinks.AzureEventHub.csproj | 55 +++++++++---------- .../AzureEventHubBatchingSink.cs | 9 +-- .../Sinks/AzureEventHub/AzureEventHubSink.cs | 10 ++-- 5 files changed, 48 insertions(+), 64 deletions(-) diff --git a/src/Serilog.Sinks.AzureEventHub/AuditLoggerConfigurationAzureEventHubExtensions.cs b/src/Serilog.Sinks.AzureEventHub/AuditLoggerConfigurationAzureEventHubExtensions.cs index dc6434d..d0deed5 100644 --- a/src/Serilog.Sinks.AzureEventHub/AuditLoggerConfigurationAzureEventHubExtensions.cs +++ b/src/Serilog.Sinks.AzureEventHub/AuditLoggerConfigurationAzureEventHubExtensions.cs @@ -14,7 +14,7 @@ using System; using System.Diagnostics.CodeAnalysis; -using Microsoft.Azure.EventHubs; +using Azure.Messaging.EventHubs.Producer; using Serilog.Configuration; using Serilog.Core; using Serilog.Events; @@ -45,7 +45,7 @@ public static class AuditLoggerConfigurationAzureEventHubExtensions /// A required parameter is null. public static LoggerConfiguration AzureEventHub( this LoggerAuditSinkConfiguration loggerConfiguration, - EventHubClient eventHubClient, + EventHubProducerClient eventHubClient, string outputTemplate = DefaultOutputTemplate, IFormatProvider formatProvider = null, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum @@ -75,7 +75,7 @@ public static LoggerConfiguration AzureEventHub( public static LoggerConfiguration AzureEventHub( this LoggerAuditSinkConfiguration loggerConfiguration, ITextFormatter formatter, - EventHubClient eventHubClient, + EventHubProducerClient eventHubClient, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum) { if (loggerConfiguration == null) @@ -115,12 +115,7 @@ public static LoggerConfiguration AzureEventHub( if (string.IsNullOrWhiteSpace(eventHubName)) throw new ArgumentNullException("eventHubName"); - var connectionstringBuilder = new EventHubsConnectionStringBuilder(connectionString) - { - EntityPath = eventHubName - }; - - var client = EventHubClient.CreateFromConnectionString(connectionstringBuilder.ToString()); + var client = new EventHubProducerClient(connectionString, eventHubName); return AzureEventHub(loggerConfiguration, client, outputTemplate, formatProvider, restrictedToMinimumLevel); } @@ -150,11 +145,7 @@ public static LoggerConfiguration AzureEventHub( if (string.IsNullOrWhiteSpace(eventHubName)) throw new ArgumentNullException("eventHubName"); - var connectionStringBuilder = new EventHubsConnectionStringBuilder(connectionString) - { - EntityPath = eventHubName - }; - var client = EventHubClient.CreateFromConnectionString(connectionStringBuilder.ToString()); + var client = new EventHubProducerClient(connectionString, eventHubName); return AzureEventHub(loggerConfiguration, formatter, client, restrictedToMinimumLevel); } } diff --git a/src/Serilog.Sinks.AzureEventHub/LoggerConfigurationAzureEventHubExtensions.cs b/src/Serilog.Sinks.AzureEventHub/LoggerConfigurationAzureEventHubExtensions.cs index 8b7821d..7889d42 100644 --- a/src/Serilog.Sinks.AzureEventHub/LoggerConfigurationAzureEventHubExtensions.cs +++ b/src/Serilog.Sinks.AzureEventHub/LoggerConfigurationAzureEventHubExtensions.cs @@ -14,7 +14,7 @@ using System; using System.Diagnostics.CodeAnalysis; -using Microsoft.Azure.EventHubs; +using Azure.Messaging.EventHubs.Producer; using Serilog.Configuration; using Serilog.Core; using Serilog.Events; @@ -59,7 +59,7 @@ public static class LoggerConfigurationAzureEventHubExtensions /// A required parameter is null. public static LoggerConfiguration AzureEventHub( this LoggerSinkConfiguration loggerConfiguration, - EventHubClient eventHubClient, + EventHubProducerClient eventHubClient, string outputTemplate = DefaultOutputTemplate, IFormatProvider formatProvider = null, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, @@ -96,7 +96,7 @@ public static LoggerConfiguration AzureEventHub( public static LoggerConfiguration AzureEventHub( this LoggerSinkConfiguration loggerConfiguration, ITextFormatter formatter, - EventHubClient eventHubClient, + EventHubProducerClient eventHubClient, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, bool writeInBatches = false, TimeSpan? period = null, @@ -153,12 +153,7 @@ public static LoggerConfiguration AzureEventHub( if (string.IsNullOrWhiteSpace(eventHubName)) throw new ArgumentNullException("eventHubName"); - var connectionstringBuilder = new EventHubsConnectionStringBuilder(connectionString) - { - EntityPath = eventHubName - }; - - var client = EventHubClient.CreateFromConnectionString(connectionstringBuilder.ToString()); + var client = new EventHubProducerClient(connectionString, eventHubName); return AzureEventHub(loggerConfiguration, client, outputTemplate, formatProvider, restrictedToMinimumLevel, writeInBatches, period, batchPostingLimit); } @@ -195,11 +190,7 @@ public static LoggerConfiguration AzureEventHub( if (string.IsNullOrWhiteSpace(eventHubName)) throw new ArgumentNullException("eventHubName"); - var connectionStringBuilder = new EventHubsConnectionStringBuilder(connectionString) - { - EntityPath = eventHubName - }; - var client = EventHubClient.CreateFromConnectionString(connectionStringBuilder.ToString()); + var client = new EventHubProducerClient(connectionString, eventHubName); return AzureEventHub(loggerConfiguration, formatter, client, restrictedToMinimumLevel, writeInBatches, period, batchPostingLimit); } diff --git a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj index a122565..877735b 100644 --- a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj +++ b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj @@ -1,29 +1,28 @@ - - Write Serilog events to Azure Event Hub - 6.0.0 - Serilog Contributors - netstandard2.0;net461 - true - Serilog.Sinks.AzureEventHub - ../../assets/Serilog.snk - true - true - Serilog.Sinks.AzureEventHub - serilog;azure;eventhub - http://serilog.net - Apache-2.0 - https://github.com/serilog/serilog-sinks-azureeventhub - git - false - Serilog - true - - - - - - - - - + + Write Serilog events to Azure Event Hub + 6.0.0 + Serilog Contributors + netstandard2.0;net461 + true + Serilog.Sinks.AzureEventHub + ../../assets/Serilog.snk + true + true + Serilog.Sinks.AzureEventHub + serilog;azure;eventhub + http://serilog.net + Apache-2.0 + https://github.com/serilog/serilog-sinks-azureeventhub + git + false + Serilog + true + + + + + + + + \ No newline at end of file diff --git a/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubBatchingSink.cs b/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubBatchingSink.cs index 945ced6..5bbbe20 100644 --- a/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubBatchingSink.cs +++ b/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubBatchingSink.cs @@ -17,7 +17,8 @@ using System.IO; using System.Text; using System.Threading.Tasks; -using Microsoft.Azure.EventHubs; +using Azure.Messaging.EventHubs; +using Azure.Messaging.EventHubs.Producer; using Serilog.Events; using Serilog.Formatting; using Serilog.Sinks.PeriodicBatching; @@ -29,7 +30,7 @@ namespace Serilog.Sinks.AzureEventHub /// public class AzureEventHubBatchingSink : PeriodicBatchingSink { - private readonly EventHubClient _eventHubClient; + private readonly EventHubProducerClient _eventHubClient; private readonly ITextFormatter _formatter; /// @@ -40,7 +41,7 @@ public class AzureEventHubBatchingSink : PeriodicBatchingSink /// /// public AzureEventHubBatchingSink( - EventHubClient eventHubClient, + EventHubProducerClient eventHubClient, ITextFormatter formatter, int batchSizeLimit, TimeSpan period) @@ -83,7 +84,7 @@ protected override Task EmitBatchAsync(IEnumerable events) batchedEvents.Add(eventHubData); } - return _eventHubClient.SendAsync(batchedEvents, batchPartitionKey); + return _eventHubClient.SendAsync(batchedEvents, new SendEventOptions() { PartitionKey = batchPartitionKey }); } } } diff --git a/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubSink.cs b/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubSink.cs index 13d1bd2..2db5e28 100644 --- a/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubSink.cs +++ b/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubSink.cs @@ -13,9 +13,11 @@ // limitations under the License. using System; +using System.Collections.Generic; using System.IO; using System.Text; -using Microsoft.Azure.EventHubs; +using Azure.Messaging.EventHubs; +using Azure.Messaging.EventHubs.Producer; using Serilog.Core; using Serilog.Events; using Serilog.Formatting; @@ -27,7 +29,7 @@ namespace Serilog.Sinks.AzureEventHub /// public class AzureEventHubSink : ILogEventSink { - readonly EventHubClient _eventHubClient; + readonly EventHubProducerClient _eventHubClient; readonly ITextFormatter _formatter; /// @@ -36,7 +38,7 @@ public class AzureEventHubSink : ILogEventSink /// The EventHubClient to use in this sink. /// Provides formatting for outputting log data public AzureEventHubSink( - EventHubClient eventHubClient, + EventHubProducerClient eventHubClient, ITextFormatter formatter) { _eventHubClient = eventHubClient; @@ -61,7 +63,7 @@ public void Emit(LogEvent logEvent) //Unfortunately no support for async in Serilog yet //https://github.com/serilog/serilog/issues/134 - _eventHubClient.SendAsync(eventHubData, Guid.NewGuid().ToString()).GetAwaiter().GetResult(); + _eventHubClient.SendAsync(new List() { eventHubData } , new SendEventOptions() { PartitionKey = Guid.NewGuid().ToString() }).GetAwaiter().GetResult(); } } } \ No newline at end of file From 4f444dc16f595b0dea552219830d655c45b5bd67 Mon Sep 17 00:00:00 2001 From: Michael McKechney Date: Fri, 21 May 2021 17:03:40 -0400 Subject: [PATCH 10/10] Updating Nuspec with Azure.Messaging.EventHubs 5.* --- .../Serilog.Sinks.AzureEventHub.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.nuspec b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.nuspec index a1e3e27..e141efc 100644 --- a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.nuspec +++ b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.nuspec @@ -14,7 +14,7 @@ - +