public PipeWriter(PipeWriterConfiguration config) : base(config.Level) { Contract.Requires(config != null); _logLevel = config.Level; _writer = InternalStableLoggerNetClient.CreateOnPipeInternal(config.ServerName, config.PipeName); _writer.Start(); }
public NetWriter(NetWriterConfiguration config) : base(config.Level) { Contract.Requires(config != null); _logLevel = config.Level; _serverName = config.ServerAddress; _port = config.Port; _writer = InternalStableLoggerNetClient.CreateOnTcpInternal(_serverName, _port); _writer.Start(); }
/// <summary> /// Отправка события логгера по сети /// </summary> public override bool Write(LoggingEvent data) { if (_isDisposed) { if (_errorTracker.CanWriteErrorGetAndUpdate()) { _thisClassSupportLogger.Error("Attempt to write LoggingEvent in Disposed state"); } return(false); } if (data.Level < _logLevel) { return(true); } bool result = false; try { lock (_lockWrite) { if (!_writer.IsStarted) { _writer.Start(); } if (!_writer.HasConnection) { if (_errorTracker.CanWriteErrorGetAndUpdate()) { _thisClassSupportLogger.Error("Connection to Pipe logger server is not established: " + _writer.RemoteSideName); } return(false); } _writer.SendData(data); result = true; } } catch (CommunicationException ex) { if (_errorTracker.CanWriteErrorGetAndUpdate()) { _thisClassSupportLogger.Error(ex, "Error while sending data to Pipe logger server: " + _writer.RemoteSideName); } } catch (TimeoutException ex) { if (_errorTracker.CanWriteErrorGetAndUpdate()) { _thisClassSupportLogger.Error(ex, "Error while sending data to Pipe logger server: " + _writer.RemoteSideName); } } catch (Exception ex) { _thisClassSupportLogger.Error(ex, "Fatal error while sending data to Pipe logger server: " + _writer.RemoteSideName); throw new LoggerNetWriteException("Fatal error while sending data to Pipe logger server: " + _writer.RemoteSideName, ex); } return(result); }