Beispiel #1
0
 /// <summary>
 /// Construct a sink that saves logs to the specified storage account. Properties are being send as data and the level is used as tag.
 /// </summary>
 /// <param name="batchSizeLimit">The maximum number of events to post in a single batch.</param>
 /// <param name="period">The time to wait between checking for event batches.</param>
 ///  <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
 /// <param name="logglyConfig">Used to configure underlying LogglyClient programmaticaly. Otherwise use app.Config.</param>
 /// <param name="includes">Decides if the sink should include specific properties in the log message</param>
 public LogglySink(IFormatProvider formatProvider, int batchSizeLimit, TimeSpan period, LogglyConfiguration logglyConfig, LogIncludes includes)
     : base(batchSizeLimit, period)
 {
     if (logglyConfig != null)
     {
         _adapter = new LogglyConfigAdapter();
         _adapter.ConfigureLogglyClient(logglyConfig);
     }
     _client    = new LogglyClient();
     _converter = new LogEventConverter(formatProvider, includes);
 }
Beispiel #2
0
        public HttpLogShipper(
            string bufferBaseFilename,
            int batchPostingLimit,
            TimeSpan period, long?
            eventBodyLimitBytes,
            LoggingLevelSwitch levelControlSwitch,
            long?retainedInvalidPayloadsLimitBytes,
            Encoding encoding,
            int?retainedFileCountLimit,
            LogglyConfiguration logglyConfiguration)
        {
            _batchPostingLimit      = batchPostingLimit;
            _retainedFileCountLimit = retainedFileCountLimit;

            _controlledSwitch   = new ControlledLevelSwitch(levelControlSwitch);
            _connectionSchedule = new ExponentialBackoffConnectionSchedule(period);

            if (logglyConfiguration != null)
            {
                _adapter = new LogglyConfigAdapter();
                _adapter.ConfigureLogglyClient(logglyConfiguration);
            }

            _logglyClient = new LogglyClient(); //we'll use the loggly client instead of HTTP directly

            //create necessary path elements
            var candidateSearchPath = Path.GetFileName(bufferBaseFilename) + "*.json";
            var logFolder           = Path.GetDirectoryName(candidateSearchPath);

            //Filebase is currently the only option available so we will stick with it directly (for now)
            var encodingToUse    = encoding;
            var bookmarkProvider = new FileBasedBookmarkProvider(bufferBaseFilename, _fileSystemAdapter, encoding);

            _bufferDataProvider   = new FileBufferDataProvider(bufferBaseFilename, _fileSystemAdapter, bookmarkProvider, encodingToUse, batchPostingLimit, eventBodyLimitBytes, retainedFileCountLimit);
            _invalidPayloadLogger = new InvalidPayloadLogger(logFolder, encodingToUse, _fileSystemAdapter, retainedInvalidPayloadsLimitBytes);

            _timer = new PortableTimer(c => OnTick());
            SetTimer();
        }