public static LoggerConfiguration AmqpSink(
            this LoggerSinkConfiguration loggerConfiguration,
            IConnection amqpConnection,
            AmqpConfiguration remoteConfiguration,
            ITextFormatter textFormatter           = null,
            IFormatProvider formatProvider         = null,
            LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose)
        {
            var _sink = new AmqpSink(amqpConfig: remoteConfiguration, amqpConnection: amqpConnection, textFormatter: textFormatter, formatProvider: formatProvider);

            return(loggerConfiguration.Sink(logEventSink: _sink));
        }
Пример #2
0
 public AmqpSink(AmqpConfiguration amqpConfig, IConnection amqpConnection, ITextFormatter textFormatter, IFormatProvider formatProvider)
 {
     this._amqpConfig = amqpConfig;
     this._amqpClient = new AmqpClient();
     this._connection = amqpConnection;
     if (amqpConfig.IsRpc)
     {
         this._amqpClient.InitiateAmqpRpc(this._connection);
         this._rpcClient = this._amqpClient.CreateAmqpRpcClient(amqpNode: this._amqpConfig.QueueName);
     }
     else
     {
         this._amqpSession = amqpConnection.CreateSession();
         this._amqpSender  = this._amqpSession.CreateSender(name: "Amqp-Serilog.Sinks.Amqp", address: this._amqpConfig.QueueName);
     }
     this._textFormatter  = textFormatter;
     this._formatProvider = formatProvider;
 }