protected override void WriteMessage(LogLevel logLevel, string logName, EventId eventId, string message, Exception exception) { var dateTime = DateTime.UtcNow; var fieldsDictionary = new Dictionary <string, string>(Options.Fields); foreach (var kvp in GetStructuredScopeInformation()) { // Overwrite later earlier scope info with more recent. fieldsDictionary[kvp.Key] = kvp.Value?.ToString(); } var splunkEventData = new SplunkEventData( PayloadTransformer.Transform( new LogData { Timestamp = dateTime.FormatForSplunk(Options.TimestampFormat), CategoryName = logName, Scope = GetTextualScopeInformation(), Level = logLevel, Event = eventId, Message = message, Exception = exception }), dateTime.FormatForSplunk(null), // JsonEventCollector must be in Epoch sec's format. Options.Host, Options.Index, Options.Source, Options.SourceType, fieldsDictionary); LoggerProcessor.EnqueueMessage(JsonConvert.SerializeObject(splunkEventData)); }
protected override void WriteMessage(LogLevel logLevel, string logName, EventId eventId, string message, Exception exception) { // Queue log message var splunkEventData = PayloadTransformer.Transform( new LogData { Timestamp = DateTime.UtcNow.FormatForSplunk(Options.TimestampFormat), CategoryName = logName, Scope = GetTextualScopeInformation(), Level = logLevel, Event = eventId, Message = message, Exception = exception }).ToString(); LoggerProcessor.EnqueueMessage(splunkEventData); }