From e5b38d74fb02682da5e8e19ab6b4b7cdcf07783c Mon Sep 17 00:00:00 2001 From: "Mattias Kindborg @FantasticFiasco" Date: Mon, 5 Apr 2021 09:53:39 +0200 Subject: [PATCH] removed: deprecated extension DurableHttp (#183) Closes #182 --- CHANGELOG.md | 60 +++++++++++++++++-- .../LoggerSinkConfigurationExtensions.cs | 34 ----------- .../DurableHttpSinkGivenAppSettingsShould.cs | 27 --------- ...bleHttpSinkGivenCodeConfigurationShould.cs | 42 ------------- .../Serilog.Sinks.HttpTests.csproj | 3 - .../appsettings_durable_http.json | 23 ------- 6 files changed, 56 insertions(+), 133 deletions(-) delete mode 100644 test/Serilog.Sinks.HttpTests/DurableHttpSinkGivenAppSettingsShould.cs delete mode 100644 test/Serilog.Sinks.HttpTests/DurableHttpSinkGivenCodeConfigurationShould.cs delete mode 100644 test/Serilog.Sinks.HttpTests/appsettings_durable_http.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ce56f3d..389c7dd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,7 +44,7 @@ log = new LoggerConfiguration() false, 10, 500, - TimeSpan.FromSeconds(10) + TimeSpan.FromSeconds(10)) .CreateLogger(); // After migration @@ -57,7 +57,7 @@ log = new LoggerConfiguration() retainedBufferFileCountLimit: 10, batchPostingLimit: 500, // the new argument batchSizeLimitBytes is positioned here - period: TimeSpan.FromSeconds(10) + period: TimeSpan.FromSeconds(10)) .CreateLogger(); ``` @@ -73,7 +73,7 @@ log = new LoggerConfiguration() false, 10, 500, - TimeSpan.FromSeconds(10) + TimeSpan.FromSeconds(10)) .CreateLogger(); // After migration @@ -86,7 +86,7 @@ log = new LoggerConfiguration() retainedBufferFileCountLimit: 10, batchPostingLimit: 500, // the new argument batchSizeLimitBytes is positioned here - period: TimeSpan.FromSeconds(10) + period: TimeSpan.FromSeconds(10)) .CreateLogger(); ``` @@ -133,6 +133,58 @@ public class MyHttpClient : IHttpClient } ``` +### :skull: Removed + +- [#182](https://github.com/FantasticFiasco/serilog-sinks-http/issues/182) Extension method `DurableHttp` which was marked as deprecated in v5.2.0 + +**Migration guide** + +Given you are configuring the sink in code you should do the following changes. + +```csharp +// Before migration +log = new LoggerConfiguration() + .WriteTo.DurableHttp(requestUri: "http://www.mylogs.com") + .CreateLogger(); + +// After migration +log = new LoggerConfiguration() + .WriteTo.DurableHttpUsingTimeRolledBuffers(requestUri: "http://www.mylogs.com") + .CreateLogger(); +``` + +Given you are configuring the sink in application configuration you should do the following changes. + +```json +// Before migration +{ + "Serilog": { + "WriteTo": [ + { + "Name": "DurableHttp", + "Args": { + "requestUri": "http://www.mylogs.com" + } + } + ] + } +} + +// After migration +{ + "Serilog": { + "WriteTo": [ + { + "Name": "DurableHttpUsingTimeRolledBuffers", + "Args": { + "requestUri": "http://www.mylogs.com" + } + } + ] + } +} +``` + ### :syringe: Fixed - Durable buffer files are no longer created with an initial [BOM](https://en.wikipedia.org/wiki/Byte_order_mark) diff --git a/src/Serilog.Sinks.Http/LoggerSinkConfigurationExtensions.cs b/src/Serilog.Sinks.Http/LoggerSinkConfigurationExtensions.cs index 90d5ed4e..20f75144 100644 --- a/src/Serilog.Sinks.Http/LoggerSinkConfigurationExtensions.cs +++ b/src/Serilog.Sinks.Http/LoggerSinkConfigurationExtensions.cs @@ -13,7 +13,6 @@ // limitations under the License. using System; -using System.ComponentModel; using Microsoft.Extensions.Configuration; using Serilog.Configuration; using Serilog.Events; @@ -127,39 +126,6 @@ public static LoggerConfiguration Http( return sinkConfiguration.Sink(sink, restrictedToMinimumLevel); } - [Obsolete("Use DurableHttpUsingTimeRolledBuffers instead of this sink provider")] - [EditorBrowsable(EditorBrowsableState.Never)] - public static LoggerConfiguration DurableHttp( - this LoggerSinkConfiguration sinkConfiguration, - string requestUri, - string bufferPathFormat = "Buffer-{Date}.json", - long? bufferFileSizeLimitBytes = null, - bool bufferFileShared = false, - int? retainedBufferFileCountLimit = 31, - int batchPostingLimit = 1000, - TimeSpan? period = null, - ITextFormatter? textFormatter = null, - IBatchFormatter? batchFormatter = null, - LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, - IHttpClient? httpClient = null, - IConfiguration? configuration = null) - { - return DurableHttpUsingTimeRolledBuffers( - sinkConfiguration: sinkConfiguration, - requestUri: requestUri, - bufferPathFormat: bufferPathFormat, - bufferFileSizeLimitBytes: bufferFileSizeLimitBytes, - bufferFileShared: bufferFileShared, - retainedBufferFileCountLimit: retainedBufferFileCountLimit, - batchPostingLimit: batchPostingLimit, - period: period, - textFormatter: textFormatter, - batchFormatter: batchFormatter, - restrictedToMinimumLevel: restrictedToMinimumLevel, - httpClient: httpClient, - configuration: configuration); - } - /// /// Adds a durable sink that sends log events using HTTP POST over the network. A durable /// sink will persist log events on disk in buffer files before sending them over the diff --git a/test/Serilog.Sinks.HttpTests/DurableHttpSinkGivenAppSettingsShould.cs b/test/Serilog.Sinks.HttpTests/DurableHttpSinkGivenAppSettingsShould.cs deleted file mode 100644 index e8c50ab6..00000000 --- a/test/Serilog.Sinks.HttpTests/DurableHttpSinkGivenAppSettingsShould.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Serilog.Core; - -namespace Serilog -{ - public class DurableHttpSinkGivenAppSettingsShould : SinkFixture - { - public DurableHttpSinkGivenAppSettingsShould() - { - DeleteBufferFiles(); - - var configuration = new ConfigurationBuilder() - .AddJsonFile("appsettings_durable_http.json") - .Build(); - - Logger = new LoggerConfiguration() - .ReadFrom.Configuration(configuration) - .CreateLogger(); - - Configuration = configuration; - } - - protected override Logger Logger { get; } - - protected override IConfiguration Configuration { get; } - } -} diff --git a/test/Serilog.Sinks.HttpTests/DurableHttpSinkGivenCodeConfigurationShould.cs b/test/Serilog.Sinks.HttpTests/DurableHttpSinkGivenCodeConfigurationShould.cs deleted file mode 100644 index 3c3d2306..00000000 --- a/test/Serilog.Sinks.HttpTests/DurableHttpSinkGivenCodeConfigurationShould.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using Microsoft.Extensions.Configuration; -using Serilog.Core; -using Serilog.Sinks.Http.BatchFormatters; -using Serilog.Sinks.Http.TextFormatters; -using Serilog.Support; - -namespace Serilog -{ - public class DurableHttpSinkGivenCodeConfigurationShould : SinkFixture - { - public DurableHttpSinkGivenCodeConfigurationShould() - { - DeleteBufferFiles(); - - var configuration = new ConfigurationBuilder().Build(); - -#pragma warning disable CS0618 // Type or member is obsolete - - Logger = new LoggerConfiguration() - .MinimumLevel.Verbose() - .WriteTo - .DurableHttp( - requestUri: "some/route", - batchPostingLimit: 100, - period: TimeSpan.FromMilliseconds(1), - textFormatter: new NormalRenderedTextFormatter(), - batchFormatter: new DefaultBatchFormatter(), - httpClient: new HttpClientMock(), - configuration: configuration) - .CreateLogger(); - -#pragma warning restore CS0618 // Type or member is obsolete - - Configuration = configuration; - } - - protected override Logger Logger { get; } - - protected override IConfiguration Configuration { get; } - } -} diff --git a/test/Serilog.Sinks.HttpTests/Serilog.Sinks.HttpTests.csproj b/test/Serilog.Sinks.HttpTests/Serilog.Sinks.HttpTests.csproj index 20134284..550c0eac 100644 --- a/test/Serilog.Sinks.HttpTests/Serilog.Sinks.HttpTests.csproj +++ b/test/Serilog.Sinks.HttpTests/Serilog.Sinks.HttpTests.csproj @@ -30,9 +30,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest diff --git a/test/Serilog.Sinks.HttpTests/appsettings_durable_http.json b/test/Serilog.Sinks.HttpTests/appsettings_durable_http.json deleted file mode 100644 index 438c10a8..00000000 --- a/test/Serilog.Sinks.HttpTests/appsettings_durable_http.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "Serilog": { - "MinimumLevel": "Verbose", - "WriteTo": [ - { - "Name": "DurableHttp", - "Args": { - "requestUri": "some/route", - "bufferPathFormat": "Buffer-{Date}.json", - "bufferFileSizeLimitBytes": null, - "bufferFileShared": false, - "retainedBufferFileCountLimit": 31, - "batchPostingLimit": 100, - "period": "00:00:00.001", - "textFormatter": "Serilog.Sinks.Http.TextFormatters.NormalRenderedTextFormatter, Serilog.Sinks.Http", - "batchFormatter": "Serilog.Sinks.Http.BatchFormatters.DefaultBatchFormatter, Serilog.Sinks.Http", - "restrictedToMinimumLevel": "Verbose", - "httpClient": "Serilog.Support.HttpClientMock, Serilog.Sinks.HttpTests" - } - } - ] - } -} \ No newline at end of file