Example #1
0
        public DurableLogglySink(
            string bufferBaseFilename,
            int batchPostingLimit,
            TimeSpan period,
            long?bufferFileSizeLimitBytes,
            long?eventBodyLimitBytes,
            LoggingLevelSwitch levelControlSwitch,
            long?retainedInvalidPayloadsLimitBytes,
            IFormatProvider formatProvider = null)
        {
            if (bufferBaseFilename == null)
            {
                throw new ArgumentNullException(nameof(bufferBaseFilename));
            }

            //handles sending events to Loggly's API through LogglyClient and manages the pending list
            _shipper = new HttpLogShipper(
                bufferBaseFilename,
                batchPostingLimit,
                period,
                eventBodyLimitBytes,
                levelControlSwitch,
                retainedInvalidPayloadsLimitBytes);

            //writes events to the file to support connection recovery
            _sink = new RollingFileSink(
                bufferBaseFilename + "-{Date}.json",
                new LogglyFormatter(formatProvider), //serializes as LogglyEvent
                bufferFileSizeLimitBytes,
                null,
                Encoding.UTF8);
        }
        public DurableLogglySink(
            string bufferBaseFilename,
            int batchPostingLimit,
            TimeSpan period,
            long?bufferFileSizeLimitBytes,
            long?eventBodyLimitBytes,
            LoggingLevelSwitch levelControlSwitch,
            long?retainedInvalidPayloadsLimitBytes,
            int?retainedFileCountLimit              = null,
            IFormatProvider formatProvider          = null,
            LogglyConfiguration logglyConfiguration = null,
            LogIncludes includes = null)
        {
            if (bufferBaseFilename == null)
            {
                throw new ArgumentNullException(nameof(bufferBaseFilename));
            }

            //use a consistent UTF encoding with BOM so no confusion will exist when reading / deserializing
            var encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);

            //handles sending events to Loggly's API through LogglyClient and manages the pending list
            _shipper = new HttpLogShipper(
                bufferBaseFilename,
                batchPostingLimit,
                period,
                eventBodyLimitBytes,
                levelControlSwitch,
                retainedInvalidPayloadsLimitBytes,
                encoding,
                retainedFileCountLimit,
                logglyConfiguration);

            //writes events to the file to support connection recovery
            _sink = new RollingFileSink(
                bufferBaseFilename + "-{Date}.json",
                new LogglyFormatter(formatProvider, includes), //serializes as LogglyEvent
                bufferFileSizeLimitBytes,
                retainedFileCountLimit,
                encoding);
        }