C# 如何使用NLog登录Amazon ElasticSearch?
我正在尝试让NLog与Amazon ElasticSearch合作 这就是我现在得到的:C# 如何使用NLog登录Amazon ElasticSearch?,c#,amazon-web-services,
elasticsearch,logging,nlog,C#,Amazon Web Services,
elasticsearch,Logging,Nlog,我正在尝试让NLog与Amazon ElasticSearch合作 这就是我现在得到的: // Step 1. Create configuration object var config = new LoggingConfiguration(); // Step 2. Create targets and add them to the configuration var awsTaget = new ElasticSearchTarget(); config.AddTarget("aw
// Step 1. Create configuration object
var config = new LoggingConfiguration();
// Step 2. Create targets and add them to the configuration
var awsTaget = new ElasticSearchTarget();
config.AddTarget("aws", awsTaget);
// Step 3. Set target properties
awsTaget.Uri = "https://amazonendpoint.com";
awsTaget.Index = "myindex" + DateTime.Now.ToString("yyyy-MM-dd");
awsTaget.DocumentType = "logevent";
awsTaget.Layout = "${message}";
// Step 4. Define rules
var rule3 = new LoggingRule("*", LogLevel.Debug, awsTaget);
config.LoggingRules.Add(rule3);
// Step 5. Activate the configuration
LogManager.Configuration = config;
// log
var _logger = LogManager.GetLogger("Example");
logger.Debug("debug log message");
我正在使用NLog和NLog.Targets.ElasticSearch。这是正确的软件包吗?由于以下错误,您需要在ElasticSearchTarget周围放置一个包装:
你的标题暗示它不起作用。会发生什么?
var awsTaget = new ElasticSearchTarget();
var awsTargetAsync = new AsyncTargetWrapper(awsTaget) { OverflowAction=AsyncTargetWrapperOverflowAction.Block, BatchSize=10, TimeToSleepBetweenBatches = 0 };
// Step 4. Define rules
var rule3 = new LoggingRule("*", LogLevel.Debug, awsTargetAsync);