/// <summary> /// <see cref="LoggerSinkConfiguration"/> extension that provides configuration chaining. /// </summary> /// <param name="loggerSinkConfiguration">Instance of <see cref="LoggerSinkConfiguration"/> object.</param> /// <param name="microsoftTeamsSinkOptions">The microsoft teams sink options object.</param> /// <param name="restrictedToMinimumLevel"><see cref="LogEventLevel"/> value that specifies minimum logging /// level that will be allowed to be logged.</param> /// <returns>Instance of <see cref="LoggerConfiguration"/> object.</returns> public static LoggerConfiguration MicrosoftTeams( this LoggerSinkConfiguration loggerSinkConfiguration, MicrosoftTeamsSinkOptions microsoftTeamsSinkOptions, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum) { if (loggerSinkConfiguration is null) { throw new ArgumentNullException(nameof(loggerSinkConfiguration)); } if (microsoftTeamsSinkOptions is null) { throw new ArgumentNullException(nameof(microsoftTeamsSinkOptions)); } if (string.IsNullOrWhiteSpace(microsoftTeamsSinkOptions.WebHookUri)) { throw new ArgumentNullException(nameof(microsoftTeamsSinkOptions.WebHookUri)); } var batchingOptions = new PeriodicBatchingSinkOptions() { BatchSizeLimit = microsoftTeamsSinkOptions.BatchSizeLimit, Period = microsoftTeamsSinkOptions.Period, QueueLimit = microsoftTeamsSinkOptions.QueueLimit }; var batchingSink = new PeriodicBatchingSink(new MicrosoftTeamsSink(microsoftTeamsSinkOptions), batchingOptions); return(loggerSinkConfiguration.Sink(batchingSink, restrictedToMinimumLevel)); }
/// <summary> /// <see cref="LoggerSinkConfiguration"/> extension that provides configuration chaining. /// </summary> /// <param name="loggerSinkConfiguration">Instance of <see cref="LoggerSinkConfiguration"/> object.</param> /// <param name="telegramSinkOptions">The Telegram sink options object.</param> /// <param name="restrictedToMinimumLevel"><see cref="LogEventLevel"/> value that specifies minimum logging /// level that will be allowed to be logged.</param> /// <returns>Instance of <see cref="LoggerConfiguration"/> object.</returns> public static LoggerConfiguration Telegram( this LoggerSinkConfiguration loggerSinkConfiguration, TelegramSinkOptions telegramSinkOptions, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum) { if (loggerSinkConfiguration is null) { throw new ArgumentNullException(nameof(loggerSinkConfiguration), "The logger sink configuration is null."); } if (telegramSinkOptions is null) { throw new ArgumentNullException(nameof(telegramSinkOptions), "The Telegram sink options are null."); } if (string.IsNullOrWhiteSpace(telegramSinkOptions.BotToken)) { throw new ArgumentNullException(nameof(telegramSinkOptions.BotToken), "The Telegram bot token is null."); } var batchingOptions = new PeriodicBatchingSinkOptions() { BatchSizeLimit = telegramSinkOptions.BatchSizeLimit, Period = telegramSinkOptions.Period }; var batchingSink = new PeriodicBatchingSink(new TelegramSink(telegramSinkOptions), batchingOptions); return(loggerSinkConfiguration.Sink(batchingSink, restrictedToMinimumLevel)); }
/// <summary> /// Adds the WriteTo.InfluxDB() extension method to <see cref="LoggerConfiguration"/>. /// </summary> public static LoggerConfiguration InfluxDB( this LoggerSinkConfiguration loggerConfiguration, InfluxDBSinkOptions sinkOptions, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum) { if (sinkOptions == null) { throw new ArgumentNullException(nameof(sinkOptions)); } var defaultOptions = new PeriodicBatchingSinkOptions(); if (sinkOptions.BatchOptions == null) { sinkOptions.BatchOptions = defaultOptions; // initialized with default from lib } if (sinkOptions.BatchOptions.QueueLimit == defaultOptions.QueueLimit) { // set back to null as don't want to have queue limit if was read null from settings file sinkOptions.BatchOptions.QueueLimit = null; } var influxDbSink = new InfluxDBSink(sinkOptions); var batchingSink = new PeriodicBatchingSink(influxDbSink, sinkOptions.BatchOptions); return(loggerConfiguration.Sink(batchingSink, restrictedToMinimumLevel)); }
/// <summary> /// Adds a sink that sends log events via email. /// </summary> /// <param name="loggerConfiguration">The logger configuration.</param> /// <param name="connectionInfo">The connection info used for</param> /// <param name="textFormatter">ITextFormatter implementation to write log entry to email.</param> /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param> /// <param name="batchPostingLimit">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="mailSubject">The subject, can be a plain string or a template such as {Timestamp} [{Level}] occurred.</param> /// <returns> /// Logger configuration, allowing configuration to continue. /// </returns> /// <exception cref="ArgumentNullException">A required parameter is null.</exception> /// <exception cref="System.ArgumentNullException">connectionInfo /// or /// textFormatter</exception> public static LoggerConfiguration Email( this LoggerSinkConfiguration loggerConfiguration, EmailConnectionInfo connectionInfo, ITextFormatter textFormatter, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, int batchPostingLimit = DefaultBatchPostingLimit, TimeSpan?period = null, string mailSubject = EmailConnectionInfo.DefaultSubject) { if (connectionInfo == null) { throw new ArgumentNullException("connectionInfo"); } if (textFormatter == null) { throw new ArgumentNullException("textFormatter"); } ITextFormatter mailSubjectFormatter = new MessageTemplateTextFormatter(mailSubject, null); var batchingPeriod = period ?? DefaultPeriod; var batchingOptions = new PeriodicBatchingSinkOptions { BatchSizeLimit = batchPostingLimit, Period = batchingPeriod, EagerlyEmitFirstEvent = false, // set default to false, not usable for emailing QueueLimit = 10000 }; var batchingSink = new PeriodicBatchingSink(new EmailSink(connectionInfo, textFormatter, mailSubjectFormatter), batchingOptions); return(loggerConfiguration.Sink(batchingSink, restrictedToMinimumLevel)); }
public static LoggerConfiguration InfluxDB( this LoggerSinkConfiguration loggerConfiguration, string applicationName, string uriString, string organizationId, string bucketName = InfluxDBDefaults.DefaultBucketName, string instanceName = null, string token = null, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, PeriodicBatchingSinkOptions batchingOptions = null, IFormatProvider formatProvider = null, bool includeFullException = false) { if (string.IsNullOrEmpty(uriString)) { throw new ArgumentNullException(nameof(uriString)); } if (!Uri.TryCreate(uriString, UriKind.Absolute, out var _)) { throw new ArgumentException($"Invalid uri : {uriString}"); } return(InfluxDB(loggerConfiguration, applicationName, new Uri(uriString), organizationId, bucketName, instanceName, token, restrictedToMinimumLevel, batchingOptions, formatProvider, includeFullException)); }
/// <summary> /// Adds a sink that sends log events via email. /// </summary> /// <param name="loggerConfiguration">The logger configuration.</param> /// <param name="emailConfig">The connection info used for </param> /// <param name="outputTemplate">A message template describing the format used to write to the sink. /// the default is "{Timestamp} [{Level}] {Message}{NewLine}{Exception}".</param> /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param> /// <param name="batchPostingLimit">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="mailSubject">The subject, can be a plain string or a template such as {Timestamp} [{Level}] occurred.</param> /// <returns>Logger configuration, allowing configuration to continue.</returns> /// <exception cref="ArgumentNullException">A required parameter is null.</exception> public static LoggerConfiguration Email( this LoggerSinkConfiguration loggerConfiguration, EmailConfig emailConfig, string outputTemplate = SerilogExtensions.DefaultOutputTemplate, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, int batchPostingLimit = DefaultBatchPostingLimit, TimeSpan?period = null, IFormatProvider formatProvider = null, string mailSubject = EmailConfig.DefaultSubject) { if (emailConfig == null) { throw new ArgumentNullException("emailConfig"); } if (!string.IsNullOrEmpty(emailConfig.EmailSubject)) { mailSubject = emailConfig.EmailSubject; } var batchingPeriod = period ?? DefaultPeriod; var textFormatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider); var mailSubjectFormatter = new MessageTemplateTextFormatter(mailSubject, formatProvider); var batchingOptions = new PeriodicBatchingSinkOptions { BatchSizeLimit = batchPostingLimit, Period = batchingPeriod, EagerlyEmitFirstEvent = false, // set default to false, not usable for emailing QueueLimit = 10000 }; var batchingSink = new PeriodicBatchingSink(new EmailSink(emailConfig, textFormatter, mailSubjectFormatter), batchingOptions); return(loggerConfiguration.Sink(batchingSink, restrictedToMinimumLevel)); }
/// <summary> /// Writes log events to Google Cloud Platform Stackdriver Logging. /// </summary> /// <param name="loggerConfiguration">Logger sink configuration.</param> /// <param name="sinkOptions">Google Cloud Logging sink options.</param> /// <param name="batchSizeLimit">The maximum number of events to include in a single batch. The defailt is 100.</param> /// <param name="period">The time to wait between checking for event batches. The default is five seconds.</param> /// <param name="queueLimit">Maximum number of events in the queue. If not specified, uses an unbounded queue.</param> /// <param name="outputTemplate">A message template describing the format used to write to the sink.</param> /// <param name="restrictedToMinimumLevel">The minimum level for events passed through the sink. Ignored when <paramref name="levelSwitch"/> is specified.</param> /// <param name="levelSwitch">A switch allowing the pass-through minimum level to be changed at runtime.</param> /// <returns>Configuration object allowing method chaining.</returns> public static LoggerConfiguration GoogleCloudLogging( this LoggerSinkConfiguration loggerConfiguration, GoogleCloudLoggingSinkOptions sinkOptions, int?batchSizeLimit = null, TimeSpan?period = null, int?queueLimit = null, string outputTemplate = null, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, LoggingLevelSwitch levelSwitch = null) { var messageTemplateTextFormatter = String.IsNullOrWhiteSpace(outputTemplate) ? null : new MessageTemplateTextFormatter(outputTemplate, null); var sink = new GoogleCloudLoggingSink( sinkOptions, messageTemplateTextFormatter ); var batchingOptions = new PeriodicBatchingSinkOptions { BatchSizeLimit = batchSizeLimit ?? 100, Period = period ?? TimeSpan.FromSeconds(5), QueueLimit = queueLimit }; var batchingSink = new PeriodicBatchingSink(sink, batchingOptions); return(loggerConfiguration.Sink(batchingSink, restrictedToMinimumLevel, levelSwitch)); }
public static LoggerConfiguration HoneycombSink(this LoggerSinkConfiguration loggerConfiguration, string teamId, string apiKey, PeriodicBatchingSinkOptions batchingOptions = default) { var honeycombSink = new HoneycombSerilogSink(teamId, apiKey); var batchingSink = new PeriodicBatchingSink(honeycombSink, batchingOptions ?? new PeriodicBatchingSinkOptions()); return(loggerConfiguration.Sink(batchingSink)); }
public ILogEventSink Create(IBatchedLogEventSink sink, MSSqlServerSinkOptions sinkOptions) { var periodicBatchingSinkOptions = new PeriodicBatchingSinkOptions { BatchSizeLimit = sinkOptions.BatchPostingLimit, Period = sinkOptions.BatchPeriod, EagerlyEmitFirstEvent = sinkOptions.EagerlyEmitFirstEvent }; return(new PeriodicBatchingSink(sink, periodicBatchingSinkOptions)); }
public static LoggerConfiguration PeriodicBatchingConsole(this LoggerSinkConfiguration sinkConfiguration) { var options = new PeriodicBatchingSinkOptions() { BatchSizeLimit = 5, Period = TimeSpan.FromSeconds(5), QueueLimit = 1000, EagerlyEmitFirstEvent = false, }; var periodicBatchingSink = new PeriodicBatchingSink(new ConsolePeriodicBatchingSink(), options); return(sinkConfiguration.Sink(periodicBatchingSink)); }
/// <param name="loggerConfiguration"></param> /// <param name="teamId">The name of the team to submit the events to</param> /// <param name="apiKey">The API key given in the Honeycomb ui</param> /// <param name="batchSizeLimit">The maximum number of events to include in a single batch.</param> /// <param name="period">The time to wait between checking for event batches.</param> public static LoggerConfiguration HoneycombSink(this LoggerSinkConfiguration loggerConfiguration, string teamId, string apiKey, int batchSizeLimit, TimeSpan period) { var batchingOptions = new PeriodicBatchingSinkOptions { BatchSizeLimit = batchSizeLimit, Period = period }; return(loggerConfiguration.HoneycombSink(teamId, apiKey, batchingOptions)); }
private static ILogEventSink CreateLineNotify(string outputTemplate, IEnumerable <string> lineNotifyTokens, HttpClient httpClient = null, IFormatProvider formatProvider = null) { if (httpClient is null) { httpClient = new HttpClient(); } var lineNotifyApiUrl = "https://notify-api.line.me/api/notify"; var textFormatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider); var sink = new LineNotifySink(httpClient, lineNotifyApiUrl, textFormatter, lineNotifyTokens); var sinkOptions = new PeriodicBatchingSinkOptions { BatchSizeLimit = 1, Period = TimeSpan.FromSeconds(1), QueueLimit = 1000 }; var logEventSink = new PeriodicBatchingSink(sink, sinkOptions); return(logEventSink); }
public static LoggerConfiguration ServerLog(this LoggerSinkConfiguration loggerSinkConfiguration, Func <HubConnectionService> hubConnectionServiceFactory) { var sink = new ServerLogSink(hubConnectionServiceFactory); var batchingOptions = new PeriodicBatchingSinkOptions { BatchSizeLimit = 100, Period = TimeSpan.FromSeconds(1), EagerlyEmitFirstEvent = true, QueueLimit = 1000 }; var batchingSink = new PeriodicBatchingSink(sink, batchingOptions); return(loggerSinkConfiguration.Sink(batchingSink)); }
public static LoggerConfiguration AMQP(this LoggerSinkConfiguration loggerSinkConfiguration, AMQPSinkOptions amqpOptions, LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose) { var amqpSink = new AMQPSink(amqpOptions); var periodicBatchingOptions = amqpOptions.PeriodicBatchingSinkOptions; var batchingOptions = new PeriodicBatchingSinkOptions { BatchSizeLimit = periodicBatchingOptions.BatchSizeLimit, Period = periodicBatchingOptions.Period, EagerlyEmitFirstEvent = periodicBatchingOptions.EagerlyEmitFirstEvent, QueueLimit = periodicBatchingOptions.QueueLimit }; var batchingSink = new PeriodicBatchingSink(amqpSink, batchingOptions); return(loggerSinkConfiguration.Sink(batchingSink, restrictedToMinimumLevel)); }
public static LoggerConfiguration AMQP(this LoggerSinkConfiguration loggerSinkConfiguration, AMQPSinkOptions amqpoptions) { var amqpSink = new AMQPSink(amqpoptions); var periodicBatchingOptions = amqpoptions.PeriodicBatchingSinkOptions; var batchingOptions = new PeriodicBatchingSinkOptions { BatchSizeLimit = periodicBatchingOptions.BatchSizeLimit, Period = periodicBatchingOptions.Period, EagerlyEmitFirstEvent = periodicBatchingOptions.EagerlyEmitFirstEvent, QueueLimit = periodicBatchingOptions.QueueLimit }; var batchingSink = new PeriodicBatchingSink(amqpSink, batchingOptions); return(loggerSinkConfiguration.Sink(batchingSink)); }
/// <summary> /// Adds the WriteTo.InfluxDB() extension method to <see cref="LoggerConfiguration"/>. /// </summary> public static LoggerConfiguration InfluxDB( this LoggerSinkConfiguration loggerConfiguration, string applicationName, Uri uri, string organizationId, string bucketName = InfluxDBDefaults.DefaultBucketName, string instanceName = null, string token = null, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, PeriodicBatchingSinkOptions batchingOptions = null, IFormatProvider formatProvider = null, bool includeFullException = false) { if (uri == null) { throw new ArgumentNullException(nameof(uri)); } if (loggerConfiguration == null) { throw new ArgumentNullException(nameof(loggerConfiguration)); } if (string.IsNullOrEmpty(bucketName)) { throw new ArgumentException(nameof(bucketName)); } var sinkOptions = new InfluxDBSinkOptions() { ApplicationName = applicationName, InstanceName = instanceName, ConnectionInfo = new InfluxDBConnectionInfo { Uri = uri, BucketName = bucketName, OrganizationId = organizationId, Token = token }, BatchOptions = batchingOptions, FormatProvider = formatProvider, IncludeFullException = includeFullException }; return(InfluxDB(loggerConfiguration, sinkOptions, restrictedToMinimumLevel)); }
public static LoggerConfiguration DbContext(this LoggerSinkConfiguration loggerConfiguration, TimeSpan?period = null, int batchSize = 100, bool eagerlyEmitFirstEvent = true, int?queueLimit = 1000, IFormatProvider formatProvider = null) { var sink = new SmartDbContextSink(formatProvider); var batchingOptions = new PeriodicBatchingSinkOptions { BatchSizeLimit = batchSize, Period = period ?? TimeSpan.FromSeconds(5), EagerlyEmitFirstEvent = eagerlyEmitFirstEvent, QueueLimit = queueLimit }; var batchingSink = new PeriodicBatchingSink(sink, batchingOptions); return(loggerConfiguration.Sink(batchingSink)); }
/// <summary> /// Adds a sink that sends log events via DingTalk Robot. /// </summary> /// <param name="loggerConfiguration">The logger configuration.</param> /// <param name="token">DingTalk Robot Token</param> /// <param name="secret">DingTalk Robot Secret</param> /// <param name="outputTemplate">A message template describing the format used to write to the sink. /// the default is "{Timestamp} [{Level}] {Message}{NewLine}{Exception}".</param> /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param> /// <param name="batchPostingLimit">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> /// <returns> /// Logger configuration, allowing configuration to continue. /// </returns> /// <exception cref="ArgumentNullException">A required parameter is null.</exception> /// <exception cref="System.ArgumentNullException">loggerConfiguration /// or /// fromEmail /// or /// toEmail</exception> public static LoggerConfiguration Robot( this LoggerSinkConfiguration loggerConfiguration, string token, string secret, string outputTemplate = DefaultOutputTemplate, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, int batchPostingLimit = DefaultBatchPostingLimit, TimeSpan?period = null, IFormatProvider formatProvider = null ) { if (loggerConfiguration == null) { throw new ArgumentNullException("loggerConfiguration"); } if (token == null) { throw new ArgumentNullException("token"); } if (secret == null) { throw new ArgumentNullException("secret"); } var batchingPeriod = period ?? DefaultPeriod; var textFormatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider); var connectionInfo = new RobotConnectionInfo { Secret = secret, Token = token }; var batchingOptions = new PeriodicBatchingSinkOptions { BatchSizeLimit = batchPostingLimit, Period = batchingPeriod, EagerlyEmitFirstEvent = false, // set default to false, not usable for emailing QueueLimit = 10000 }; var batchingSink = new PeriodicBatchingSink(new RobotSink(connectionInfo, textFormatter), batchingOptions); return(loggerConfiguration.Sink(batchingSink, restrictedToMinimumLevel)); }
private static LoggerConfiguration Kafka( this LoggerSinkConfiguration loggerConfiguration, string bootstrapServers, int batchSizeLimit, int period, SecurityProtocol securityProtocol, SaslMechanism saslMechanism, string saslUsername, string saslPassword, string sslCaLocation, string topic, Func <LogEvent, string> topicDecider, ITextFormatter formatter) { var kafkaSink = new KafkaSink( bootstrapServers, securityProtocol, saslMechanism, saslUsername, saslPassword, sslCaLocation, topic, topicDecider, formatter); var batchingOptions = new PeriodicBatchingSinkOptions { BatchSizeLimit = batchSizeLimit, Period = TimeSpan.FromSeconds(period) }; var batchingSink = new PeriodicBatchingSink( kafkaSink, batchingOptions); return(loggerConfiguration .Sink(batchingSink)); }
/// <summary> /// Write log events to a <a href="https://datalust.co/seq">Seq</a> server. /// </summary> /// <param name="loggerSinkConfiguration">The logger configuration.</param> /// <param name="serverUrl">The base URL of the Seq server that log events will be written to.</param> /// <param name="restrictedToMinimumLevel">The minimum log event level required /// in order to write an event to the sink.</param> /// <param name="batchPostingLimit">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="bufferBaseFilename">Path for a set of files that will be used to buffer events until they /// can be successfully transmitted across the network. Individual files will be created using the /// pattern <paramref name="bufferBaseFilename"/>*.json, which should not clash with any other filenames /// in the same directory.</param> /// <param name="apiKey">A Seq <i>API key</i> that authenticates the client to the Seq server.</param> /// <param name="bufferSizeLimitBytes">The maximum amount of data, 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="eventBodyLimitBytes">The maximum size, in bytes, that the JSON representation of /// an event may take before it is dropped rather than being sent to the Seq server. Specify null for no limit. /// The default is 265 KB.</param> /// <param name="controlLevelSwitch">If provided, the switch will be updated based on the Seq server's level setting /// for the corresponding API key. Passing the same key to MinimumLevel.ControlledBy() will make the whole pipeline /// dynamically controlled. Do not specify <paramref name="restrictedToMinimumLevel"/> with this setting.</param> /// <param name="messageHandler">Used to construct the HttpClient that will send the log messages to Seq.</param> /// <param name="retainedInvalidPayloadsLimitBytes">A soft limit for the number of bytes to use for storing failed requests. /// The limit is soft in that it can be exceeded by any single error payload, but in that case only that single error /// payload will be retained.</param> /// <param name="queueSizeLimit">The maximum number of events that will be held in-memory while waiting to ship them to /// Seq. Beyond this limit, events will be dropped. The default is 100,000. Has no effect on /// durable log shipping.</param> /// <returns>Logger configuration, allowing configuration to continue.</returns> /// <exception cref="ArgumentNullException">A required parameter is null.</exception> public static LoggerConfiguration Seq( this LoggerSinkConfiguration loggerSinkConfiguration, string serverUrl, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, int batchPostingLimit = DefaultBatchPostingLimit, TimeSpan?period = null, string?apiKey = null, string?bufferBaseFilename = null, long?bufferSizeLimitBytes = null, long?eventBodyLimitBytes = 256 *1024, LoggingLevelSwitch?controlLevelSwitch = null, HttpMessageHandler?messageHandler = null, long?retainedInvalidPayloadsLimitBytes = null, int queueSizeLimit = DefaultQueueSizeLimit) { if (loggerSinkConfiguration == null) { throw new ArgumentNullException(nameof(loggerSinkConfiguration)); } if (serverUrl == null) { throw new ArgumentNullException(nameof(serverUrl)); } if (bufferSizeLimitBytes is < 0) { throw new ArgumentOutOfRangeException(nameof(bufferSizeLimitBytes), "Negative value provided; buffer size limit must be non-negative."); } if (queueSizeLimit < 0) { throw new ArgumentOutOfRangeException(nameof(queueSizeLimit), "Queue size limit must be non-zero."); } var defaultedPeriod = period ?? DefaultPeriod; var controlledSwitch = new ControlledLevelSwitch(controlLevelSwitch); ILogEventSink sink; if (bufferBaseFilename == null) { var batchedSink = new BatchedSeqSink( new SeqIngestionApiClient(serverUrl, apiKey, messageHandler), eventBodyLimitBytes, controlledSwitch); var options = new PeriodicBatchingSinkOptions { BatchSizeLimit = batchPostingLimit, Period = defaultedPeriod, QueueLimit = queueSizeLimit }; sink = new PeriodicBatchingSink(batchedSink, options); } else { #if DURABLE sink = new DurableSeqSink( serverUrl, bufferBaseFilename, apiKey, batchPostingLimit, defaultedPeriod, bufferSizeLimitBytes, eventBodyLimitBytes, controlledSwitch, messageHandler, retainedInvalidPayloadsLimitBytes); #else // We keep the API consistent for easier packaging and to support bait-and-switch. throw new NotSupportedException("Durable log shipping is not supported on this platform."); #endif } return(loggerSinkConfiguration.Conditional( controlledSwitch.IsIncluded, wt => wt.Sink(sink, restrictedToMinimumLevel))); }
public static LoggerConfiguration ProphetAsync(this LoggerSinkConfiguration loggerConfiguration, PeriodicBatchingSinkOptions batchingSinkOptions, string serviceName, Guid instanceId, string bootstrapServers = "localhost:9092", string topic = "prophet") { var batchedSink = new PeriodicBatchingSink(new BatchedProphetSink(serviceName, instanceId, bootstrapServers, topic), batchingSinkOptions); return(loggerConfiguration.Sink(batchedSink)); }