protected void Cleanup() { if (_stream != null) { _stream.Dispose(); _stream = null; } if (_tcpClient != null) { _tcpClient.Client.Dispose(); _tcpClient = null; } _emitter = null; }
protected async Task EnsureConnectedAsync() { try { if (IsConnected()) { return; } InitializeTcpClient(); await _tcpClient.ConnectAsync(_options.Host, _options.Port); _stream = _tcpClient.GetStream(); _emitter = new FluentdEmitter(_stream); SelfLog.WriteLine($"[Serilog.Sinks.Fluentd] Connection is established at {_options.Host}:{_options.Port}."); } catch (Exception ex) { SelfLog.WriteLine($"[Serilog.Sinks.Fluentd] Connection exception {ex.Message}\n{ex.StackTrace}"); } }