protected override void Append(LoggingEvent loggingEvent) { var probasContent = new ProbasContent(loggingEvent, Layout); var logs = new List <LogInfo> { new LogInfo { Time = DateTimeOffset.Now, Contents = probasContent.Contents } }; var tags = new Dictionary <string, string>(); var source = "netapi"; var logGroupInfo = new LogGroupInfo { Logs = logs, LogTags = tags, Topic = Settings.Topic, Source = source }; var request = new PostLogsRequest(Settings.Logstore, logGroupInfo); var result = _client.PostLogStoreLogsAsync(request).Result; if (!result.IsSuccess) { var error = new Exception(result.Error.ToString()); var msg = $"post log store logs failed {result.RequestId}"; ErrorHandler.Error(msg, error); Console.WriteLine(msg, error); } else { Console.WriteLine($"post log store logs request id {result.RequestId}"); } }
protected override void Append(LoggingEvent loggingEvent) { var probasContent = new ProbasContent(loggingEvent, Layout); try { _producer.Produce(Settings.Logstore, new Message <Null, string> { Value = probasContent.Content }, delivery => { if (delivery.Error.IsError) { var error = new Exception(delivery.Error.Reason); var msg = $"producer delivery error {delivery.Topic}"; ErrorHandler.Error(msg, error); Console.WriteLine(msg, error); } else { Console.WriteLine($"producer delivered message to {delivery.TopicPartitionOffset}"); } }); } catch (Exception ex) { var msg = $"producer delivery error {Settings.Logstore}"; ErrorHandler.Error(msg, ex); Console.WriteLine(msg, ex); } }