示例#1
0
        public ElasticSearchAppender(IElasticClientFactory clientFactory, LogEventSmartFormatter indexName,
                                     LogEventSmartFormatter indexType, IIndexingTimer timer, ITolerateCallsFactory tolerateCallsFactory,
                                     ILogBulkSet bulk, ILogEventConverterFactory logEventConverterFactory, ElasticAppenderFilters elasticFilters,
                                     IFileAccessor fileAccessor, IExternalEventWriter eventWriter)
        {
            _logEventConverterFactory = logEventConverterFactory;
            _elasticClientFactory     = clientFactory;
            IndexName             = indexName;
            IndexType             = indexType;
            _timer                = timer;
            _timer.Elapsed       += (o, e) => DoIndexNow();
            _tolerateCallsFactory = tolerateCallsFactory;
            _bulk         = bulk;
            _fileAccessor = fileAccessor;
            _eventWriter  = eventWriter;

            FixedFields               = FixFlags.Partial;
            SerializeObjects          = true;
            BulkSize                  = 2000;
            BulkIdleTimeout           = 5000;
            DropEventsOverBulkLimit   = false;
            TotalDropEventLimit       = null;
            TimeoutToWaitForTimer     = 5000;
            ElasticSearchTimeout      = 10000;
            IndexAsync                = true;
            Template                  = null;
            AllowSelfSignedServerCert = false;
            Ssl                  = false;
            _tolerateCalls       = _tolerateCallsFactory.Create(0);
            Servers              = new ServerDataCollection();
            ElasticFilters       = elasticFilters;
            AuthenticationMethod = new AuthenticationMethodChooser();
            IndexOperationParams = new IndexOperationParamsDictionary();
        }
        public ElasticSearchAppender()
        {
            FixedFields      = FixFlags.Partial;
            SerializeObjects = true;

            BulkSize                = 2000;
            BulkIdleTimeout         = 5000;
            DropEventsOverBulkLimit = false;
            TimeoutToWaitForTimer   = 5000;

            _tolerateCalls = new TolerateCallsBase();

            Servers = new ServerDataCollection();
            ElasticSearchTimeout = 10000;
            //DatePostfixFormat = "yyyy.MM.dd";
            IndexName       = $"LogEvent-{DatePostfixFormat}";
            IndexType       = "LogEvent";
            IndexAsync      = true;
            Template        = null;
            LogEventFactory = new BasicLogEventFactory();

            _timer         = new Timer(TimerElapsed, null, Timeout.Infinite, Timeout.Infinite);
            ElasticFilters = new ElasticAppenderFilters();

            AllowSelfSignedServerCert = false;
            Ssl = false;
            AuthenticationMethod = new AuthenticationMethodChooser();
            IndexOperationParams = new IndexOperationParamsDictionary();
        }
示例#3
0
        public void AddEventToBulk(Dictionary <string, object> logEvent, LogEventSmartFormatter indexNameFormat,
                                   LogEventSmartFormatter indexTypeFormat, IndexOperationParamsDictionary indexOperationParams)
        {
            var indexName = indexNameFormat.Format(logEvent).ToLower();
            var indexType = indexTypeFormat.Format(logEvent);
            var indexOperationParamValues = indexOperationParams.ToDictionary(logEvent);

            var operation = new InnerBulkOperation
            {
                Document             = logEvent,
                IndexName            = indexName,
                IndexType            = indexType,
                IndexOperationParams = indexOperationParamValues
            };

            lock (_lock)
            {
                _currentBulk.Add(operation);
            }
        }