Пример #1
0
        protected override void EmitBatch(IEnumerable <LogEvent> events)
        {
            if (!events.Any())
            {
                return;
            }

            lock (this)
            {
                if (_client == null)
                {
                    // connect or reconnect to the endpoint
                    _client = new LogmaticClient(_clientConfig);
                }
            }

            // format the event
            var payload = new StringBuilder();
            var sw      = new StringWriter(payload);

            foreach (var logEvent in events)
            {
                payload.Append(_token).Append(" ");
                _formatter.Format(logEvent, sw);
            }
            // send the event
            _client.writeAndRetry(payload.ToString());
        }
Пример #2
0
 protected override void Dispose(bool disposing)
 {
     if (_client != null)
     {
         _client.flush();
         _client.close();
         _client = null;
     }
     base.Dispose(disposing);
 }