/// <summary>
        /// Adds a durable sink that sends log events using HTTP POST over the network. A durable
        /// sink will persist log events on disk before sending them over the network, thus
        /// protecting against data loss after a system or process restart.
        /// </summary>
        /// <param name="sinkConfiguration">The logger configuration.</param>
        /// <param name="requestUri">The URI the request is sent to.</param>
        /// <param name="bufferBaseFilename">
        /// The path for a set of files that will be used to buffer events until they can be
        /// successfully sent over the network. Individual files will be created using the
        /// pattern <paramref name="bufferBaseFilename"/>-{Date}.json. Default value is 'Buffer'.
        /// </param>
        /// <param name="bufferFileSizeLimitBytes"></param>
        /// The maximum size, in bytes, to which the buffer log file for a specific date will be
        /// allowed to grow. By default no limit will be applied.
        /// <param name="batchPostingLimit">
        /// The maximum number of events to post in a single batch. Default value is 1000.
        /// </param>
        /// <param name="period">
        /// The time to wait between checking for event batches. Default value is 2 seconds.
        /// </param>
        /// <param name="textFormatter">
        /// The formatter rendering individual log events into text, for example JSON. Default
        /// value is <see cref="NormalRenderedTextFormatter"/>.
        /// </param>
        /// <param name="batchFormatter">
        /// The formatter batching multiple log events into a payload that can be sent over the
        /// network. Default value is <see cref="DefaultBatchFormatter"/>.
        /// </param>
        /// <param name="restrictedToMinimumLevel">
        /// The minimum level for events passed through the sink. Default value is
        /// <see cref="LevelAlias.Minimum"/>.
        /// </param>
        /// <param name="httpClient">
        /// A custom <see cref="IHttpClient"/> implementation. Default value is
        /// <see cref="HttpClient"/>.
        /// </param>
        /// <returns>Logger configuration, allowing configuration to continue.</returns>
        public static LoggerConfiguration DurableHttp(
            this LoggerSinkConfiguration sinkConfiguration,
            string requestUri,
            string bufferBaseFilename     = "Buffer",
            long?bufferFileSizeLimitBytes = null,
            int batchPostingLimit         = 1000,
            TimeSpan?period = null,
            ITextFormatter textFormatter           = null,
            IBatchFormatter batchFormatter         = null,
            LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
            IHttpClient httpClient = null)
        {
            if (sinkConfiguration == null)
            {
                throw new ArgumentNullException(nameof(sinkConfiguration));
            }

            var sink = new DurableHttpSink(
                requestUri,
                bufferBaseFilename,
                bufferFileSizeLimitBytes,
                batchPostingLimit,
                period ?? TimeSpan.FromSeconds(2),
                textFormatter ?? new NormalRenderedTextFormatter(),
                batchFormatter ?? new DefaultBatchFormatter(),
                httpClient ?? new HttpClientWrapper());

            return(sinkConfiguration.Sink(sink, restrictedToMinimumLevel));
        }
        /// <summary>
        /// Adds a durable sink that sends log events using HTTP POST over the network. A durable
        /// sink will persist log events on disk before sending them over the network, thus
        /// protecting against data loss after a system or process restart.
        /// </summary>
        /// <param name="sinkConfiguration">The logger configuration.</param>
        /// <param name="requestUri">The URI the request is sent to.</param>
        /// <param name="bufferPathFormat">
        /// The path format for a set of files that will be used to buffer events until they can be
        /// successfully sent over the network. Default value is "Buffer-{Date}.json". To use file
        /// rotation that is on an 30 or 60 minute interval pass "Buffer-{Hour}.json" or
        /// "Buffer-{HalfHour}.json".
        /// </param>
        /// <param name="bufferFileSizeLimitBytes">
        /// The maximum size, in bytes, to which the buffer log file for a specific date will be
        /// allowed to grow. By default no limit will be applied.
        /// </param>
        /// <param name="retainedBufferFileCountLimit">
        /// The maximum number of buffer files that will be retained, including the current buffer
        /// file. Under normal operation only 2 files will be kept, however if the log server is
        /// unreachable, the number of files specified by <paramref name="retainedBufferFileCountLimit"/>
        /// will be kept on the file system. For unlimited retention, pass null. Default value is 31.
        /// </param>
        /// <param name="batchPostingLimit">
        /// The maximum number of events to post in a single batch. Default value is 1000.
        /// </param>
        /// <param name="period">
        /// The time to wait between checking for event batches. Default value is 2 seconds.
        /// </param>
        /// <param name="textFormatter">
        /// The formatter rendering individual log events into text, for example JSON. Default
        /// value is <see cref="NormalRenderedTextFormatter"/>.
        /// </param>
        /// <param name="batchFormatter">
        /// The formatter batching multiple log events into a payload that can be sent over the
        /// network. Default value is <see cref="DefaultBatchFormatter"/>.
        /// </param>
        /// <param name="restrictedToMinimumLevel">
        /// The minimum level for events passed through the sink. Default value is
        /// <see cref="LevelAlias.Minimum"/>.
        /// </param>
        /// <param name="httpClient">
        /// A custom <see cref="IHttpClient"/> implementation. Default value is
        /// <see cref="HttpClient"/>.
        /// </param>
        /// <returns>Logger configuration, allowing configuration to continue.</returns>
        public static LoggerConfiguration DurableHttp(
            this LoggerSinkConfiguration sinkConfiguration,
            string requestUri,
            string bufferPathFormat          = "Buffer-{Date}.json",
            long?bufferFileSizeLimitBytes    = null,
            int?retainedBufferFileCountLimit = 31,
            int batchPostingLimit            = 1000,
            TimeSpan?period = null,
            ITextFormatter textFormatter           = null,
            IBatchFormatter batchFormatter         = null,
            LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
            IHttpClient httpClient = null)
        {
            if (sinkConfiguration == null)
            {
                throw new ArgumentNullException(nameof(sinkConfiguration));
            }

            // Default values
            period         = period ?? TimeSpan.FromSeconds(2);
            textFormatter  = textFormatter ?? new NormalRenderedTextFormatter();
            batchFormatter = batchFormatter ?? new DefaultBatchFormatter();
            httpClient     = httpClient ?? new DefaultHttpClient();

            var sink = new DurableHttpSink(
                requestUri,
                bufferPathFormat,
                bufferFileSizeLimitBytes,
                retainedBufferFileCountLimit,
                batchPostingLimit,
                period.Value,
                textFormatter,
                batchFormatter,
                httpClient);

            return(sinkConfiguration.Sink(sink, restrictedToMinimumLevel));
        }