public PeriodicBatchingGraylogSink(BatchingGraylogSinkOptions options, int batchSizeLimit, TimeSpan period, int queueLimit) : base(batchSizeLimit, period, queueLimit)
        {
            ISinkComponentsBuilder sinkComponentsBuilder = new SinkComponentsBuilder(options);

            _transport = new Lazy <ITransport>(() => sinkComponentsBuilder.MakeTransport());
            _converter = new Lazy <IGelfConverter>(() => sinkComponentsBuilder.MakeGelfConverter());
        }
Пример #2
0
        /// <summary>
        /// Graylogs the specified options.
        /// </summary>
        /// <param name="loggerSinkConfiguration">The logger sink configuration.</param>
        /// <param name="options">The options.</param>
        /// <returns></returns>
        public static LoggerConfiguration Graylog(this LoggerSinkConfiguration loggerSinkConfiguration,
                                                  BatchingGraylogSinkOptions options)
        {
            var sink = (ILogEventSink) new PeriodicBatchingGraylogSink(options);

            return(loggerSinkConfiguration.Sink(sink, options.MinimumLogEventLevel));
        }
Пример #3
0
        /// <summary>
        /// Graylogs the specified hostname or address.
        /// </summary>
        /// <param name="loggerSinkConfiguration">The logger sink configuration.</param>
        /// <param name="hostnameOrAddress">The hostname or address.</param>
        /// <param name="port">The port.</param>
        /// <param name="batchSizeLimit">The batchsize limit.</param>
        /// <param name="period">The batching period.</param>
        /// <param name="queueLimit">The queue limit.</param>
        /// <param name="transportType">Type of the transport.</param>
        /// <param name="minimumLogEventLevel">The minimum log event level.</param>
        /// <param name="messageIdGeneratorType">Type of the message identifier generator.</param>
        /// <param name="shortMessageMaxLength">Short length of the message maximum.</param>
        /// <param name="stackTraceDepth">The stack trace depth.</param>
        /// <param name="facility">The facility.</param>
        /// <returns></returns>
        public static LoggerConfiguration Graylog(this LoggerSinkConfiguration loggerSinkConfiguration,
                                                  string hostnameOrAddress,
                                                  int port,
                                                  int batchSizeLimit,
                                                  TimeSpan period,
                                                  int queueLimit,
                                                  TransportType transportType,
                                                  LogEventLevel minimumLogEventLevel            = LevelAlias.Minimum,
                                                  MessageIdGeneratortype messageIdGeneratorType = GraylogSinkOptionsBase.DefaultMessageGeneratorType,
                                                  int shortMessageMaxLength = GraylogSinkOptionsBase.DefaultShortMessageMaxLength,
                                                  int stackTraceDepth       = GraylogSinkOptionsBase.DefaultStackTraceDepth,
                                                  string facility           = GraylogSinkOptionsBase.DefaultFacility)
        {
            var options = new BatchingGraylogSinkOptions
            {
                HostnameOrAddress = hostnameOrAddress,
                Port                  = port,
                BatchSizeLimit        = batchSizeLimit,
                Period                = period,
                QueueLimit            = queueLimit,
                TransportType         = transportType,
                MinimumLogEventLevel  = minimumLogEventLevel,
                MessageGeneratorType  = messageIdGeneratorType,
                ShortMessageMaxLength = shortMessageMaxLength,
                StackTraceDepth       = stackTraceDepth,
                Facility              = facility,
            };

            return(loggerSinkConfiguration.Graylog(options));
        }
Пример #4
0
        /// <summary>
        /// Graylogs the specified hostname or address.
        /// </summary>
        /// <param name="loggerSinkConfiguration">The logger sink configuration.</param>
        /// <param name="hostnameOrAddress">The hostname or address.</param>
        /// <param name="port">The port.</param>
        /// <param name="transportType">Type of the transport.</param>
        /// <param name="minimumLogEventLevel">The minimum log event level.</param>
        /// <param name="messageIdGeneratorType">Type of the message identifier generator.</param>
        /// <param name="shortMessageMaxLength">Short length of the message maximum.</param>
        /// <param name="stackTraceDepth">The stack trace depth.</param>
        /// <param name="facility">The facility.</param>
        /// <param name="batchSizeLimit">The batch size limit</param>
        /// <param name="period">The period limit default is one second</param>
        /// <param name="queueLimit">queue limit</param>
        /// <param name="maxMessageSizeInUdp">the maxMessageSizeInUdp</param>
        /// <param name="includeMessageTemplate">if set to <c>true</c> if include message template to graylog.</param>
        /// <param name="messageTemplateFieldName">Name of the message template field.</param>
        /// <returns></returns>
        public static LoggerConfiguration Graylog(this LoggerSinkConfiguration loggerSinkConfiguration,
                                                  string hostnameOrAddress,
                                                  int port,
                                                  TransportType transportType,
                                                  LogEventLevel minimumLogEventLevel            = LevelAlias.Minimum,
                                                  MessageIdGeneratorType messageIdGeneratorType = GraylogSinkOptionsBase.DefaultMessageGeneratorType,
                                                  int shortMessageMaxLength       = GraylogSinkOptionsBase.DefaultShortMessageMaxLength,
                                                  int stackTraceDepth             = GraylogSinkOptionsBase.DefaultStackTraceDepth,
                                                  string facility                 = GraylogSinkOptionsBase.DefaultFacility,
                                                  int maxMessageSizeInUdp         = GraylogSinkOptionsBase.DefaultMaxMessageSizeInUdp,
                                                  int batchSizeLimit              = 10,
                                                  TimeSpan period                 = default,
                                                  int queueLimit                  = 1000,
                                                  bool includeMessageTemplate     = false,
                                                  string messageTemplateFieldName = GraylogSinkOptionsBase.DefaultMessageTemplateFieldName
                                                  )
        {
            if (period == default)
            {
                period = TimeSpan.FromSeconds(1);
            }

            // ReSharper disable once UseObjectOrCollectionInitializer
            var options = new BatchingGraylogSinkOptions();

            options.HostnameOrAddress = hostnameOrAddress;
            options.Port                     = port;
            options.TransportType            = transportType;
            options.MinimumLogEventLevel     = minimumLogEventLevel;
            options.MessageGeneratorType     = messageIdGeneratorType;
            options.ShortMessageMaxLength    = shortMessageMaxLength;
            options.StackTraceDepth          = stackTraceDepth;
            options.Facility                 = facility;
            options.BatchSizeLimit           = batchSizeLimit;
            options.Period                   = period;
            options.QueueLimit               = queueLimit;
            options.MaxMessageSizeInUdp      = maxMessageSizeInUdp;
            options.IncludeMessageTemplate   = includeMessageTemplate;
            options.MessageTemplateFieldName = messageTemplateFieldName;

            return(loggerSinkConfiguration.Graylog(options));
        }
 public PeriodicBatchingGraylogSink(BatchingGraylogSinkOptions options) : this(options, options.BatchSizeLimit, options.Period, options.QueueLimit)
 {
 }