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); }
public LogglyFormatter(IFormatProvider formatProvider, LogIncludes includes) { //the converter should receive the format provider used, in order to // handle dateTimes and dateTimeOffsets in a controlled manner _converter = new LogEventConverter(formatProvider, includes); }
/// <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); }
public LogEventConverter(IFormatProvider formatProvider = null, LogIncludes includes = null) { _formatProvider = formatProvider; _includes = includes ?? new LogIncludes(); }