public HttpImporter(LogBuffer logBuffer, SeqImportConfig importConfig) { if (logBuffer == null) { throw new ArgumentNullException(nameof(logBuffer)); } if (importConfig == null) { throw new ArgumentNullException(nameof(importConfig)); } if (string.IsNullOrWhiteSpace(importConfig.ServerUrl)) { throw new ArgumentException("The destination Seq server URL must be provided."); } _logBuffer = logBuffer; _importConfig = importConfig; var baseUri = importConfig.ServerUrl; if (!baseUri.EndsWith("/")) { baseUri += "/"; } _httpClient = new HttpClient { BaseAddress = new Uri(baseUri) }; }
static async Task Run(string server, string apiKey, string file, IDictionary <string, string> additionalTags, ulong bodyLimitBytes, ulong payloadLimitBytes) { var originalFilename = Path.GetFileName(file); Log.Information("Opening JSON log file {OriginalFilename}", originalFilename); var importId = Guid.NewGuid(); var tags = new Dictionary <string, object> { ["ImportId"] = importId }; if (additionalTags?.Any() ?? false) { Log.Information("Adding tags {@Tags} to import", additionalTags); foreach (var p in additionalTags) { tags.Add(p.Key, p.Value); } } var logBuffer = new LogBuffer(file, tags); var shipper = new HttpImporter(logBuffer, new SeqImportConfig { ServerUrl = server, ApiKey = apiKey, EventBodyLimitBytes = bodyLimitBytes, RawPayloadLimitBytes = payloadLimitBytes }); var sw = Stopwatch.StartNew(); Log.Information("Starting import {ImportId}", importId); await shipper.Import(); sw.Stop(); Log.Information("Import {ImportId} completes in {Elapsed:0.0} ms", importId, sw.Elapsed.TotalMilliseconds); }