NLog.Config elastic search target: 

```
  <target name="elasticWrapper" xsi:type="BufferingWrapper" flushTimeout="5000">
          <target xsi:type="ElasticSearch"
                  name="elastic"
                  connectionStringName="ElasticUrl"
                  index="logs-${date:format=yyyy.MM.dd}"
                  documentType="logevent"
                  includeAllProperties="true"
                  layout="${message}">       
          </target>
        </target>

```

The connectionstringname attribute for elastic search target is used to get information from appsettings.json

appsettings.json is shown below

```
{
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    }
  },
  "ConnectionStrings": {
    "ElasticUrl": "http://XXXXXX-XXXXXX:9200"
  }
}

```

Program.cs file from .Net Core project as shown below

```
public static void Main(string[] args)
{
    var config = new ConfigurationBuilder()
        .SetBasePath(Directory.GetCurrentDirectory())
        .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
        .Build();

    NLogBuilder.ConfigureNLog("nLog.config");
    foreach (var setting in config.GetChildren().ToDictionary(x => x.Key, x => x.Value))
    {
        LogManager.Configuration.Variables[setting.Key] = setting.Value;
    }
    var logger = LogManager.GetCurrentClassLogger();  
    var host = WebHost.CreateDefaultBuilder(args)                   
                      .UseContentRoot(Directory.GetCurrentDirectory())
                      .UseNLog()  
                      .Build();

        host.Run();     

}

```