Exemple #1
0
        public FileSizeRolledDurableHttpSink(
            string requestUri,
            string bufferBaseFileName,
            long?bufferFileSizeLimitBytes,
            bool bufferFileShared,
            int?retainedBufferFileCountLimit,
            long?logEventLimitBytes,
            int?logEventsInBatchLimit,
            long?batchSizeLimitBytes,
            TimeSpan period,
            ITextFormatter textFormatter,
            IBatchFormatter batchFormatter,
            IHttpClient httpClient)
        {
            shipper = new HttpLogShipper(
                httpClient,
                requestUri,
                new FileSizeRolledBufferFiles(new DirectoryService(), bufferBaseFileName),
                logEventLimitBytes,
                logEventsInBatchLimit,
                batchSizeLimitBytes,
                period,
                batchFormatter);

            sink = CreateFileSink(
                bufferBaseFileName,
                bufferFileSizeLimitBytes,
                bufferFileShared,
                retainedBufferFileCountLimit,
                textFormatter);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TimeRolledDurableHttpSink"/> class.
        /// </summary>
        public TimeRolledDurableHttpSink(
            string requestUri,
            string bufferPathFormat,
            long?bufferFileSizeLimitBytes,
            bool bufferFileShared,
            int?retainedBufferFileCountLimit,
            int batchPostingLimit,
            long batchSizeLimitBytes,
            TimeSpan period,
            ITextFormatter textFormatter,
            IBatchFormatter batchFormatter,
            IHttpClient httpClient)
        {
            if (bufferFileSizeLimitBytes < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(bufferFileSizeLimitBytes), "Negative value provided; file size limit must be non-negative.");
            }

            shipper = new HttpLogShipper(
                httpClient,
                requestUri,
                new TimeRolledBufferFiles(new DirectoryService(), bufferPathFormat),
                batchPostingLimit,
                batchSizeLimitBytes,
                period,
                batchFormatter);

            sink = new RollingFileSink(
                bufferPathFormat,
                textFormatter,
                bufferFileSizeLimitBytes,
                retainedBufferFileCountLimit,
                Encoding.UTF8,
                shared: bufferFileShared);
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FileSizeRolledDurableHttpSink"/> class.
        /// </summary>
        public FileSizeRolledDurableHttpSink(
            string requestUri,
            string bufferBaseFileName,
            long?bufferFileSizeLimitBytes,
            bool bufferFileShared,
            int?retainedBufferFileCountLimit,
            int batchPostingLimit,
            long batchSizeLimitBytes,
            TimeSpan period,
            ITextFormatter textFormatter,
            IBatchFormatter batchFormatter,
            IHttpClient httpClient)
        {
            if (bufferFileSizeLimitBytes < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(bufferFileSizeLimitBytes), "Negative value provided; file size limit must be non-negative.");
            }

            shipper = new HttpLogShipper(
                httpClient,
                requestUri,
                new FileSizeRolledBufferFiles(new DirectoryService(), bufferBaseFileName),
                batchPostingLimit,
                batchSizeLimitBytes,
                period,
                batchFormatter);

            sink = new LoggerConfiguration()
                   .WriteTo.File(
                textFormatter,
                $"{bufferBaseFileName}-.json",
                fileSizeLimitBytes: bufferFileSizeLimitBytes,
                shared: bufferFileShared,
                rollOnFileSizeLimit: true,
                retainedFileCountLimit: retainedBufferFileCountLimit,
                rollingInterval: RollingInterval.Day,
                encoding: Encoding.UTF8)
                   .CreateLogger();
        }