asp.net core项目 Nlog直接写入集群ElasticSearch的配置方法

1、NuGet 项目引用

NLog.Web.AspNetCore

NLog.Targets.ElasticSearch

 

2、nlog.config配置文件:

"1.0" encoding="utf-8" ?>
"http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true">

  
  
    "NLog.Web.AspNetCore"/>
    "NLog.Targets.ElasticSearch"/>
  

  
  async="true">
    "BufferingWrapper" name="ElasticSearch" flushTimeout="5000">
      "ElasticSearch"
              uri="http://ip地址1:端口,http://ip地址2:端口,http://ip地址3:端口"
              index="mycore-web-${shortdate}"
              includeAllProperties="true">
        "machinename" layout="${machinename}" />
        "date" layout="${longdate}" />
        "logger" layout="${logger}" />
        "stacktrace" layout="${stacktrace}" />
        "threadid" layout="${threadid}" />
        "url" layout="${aspnet-request-url:IncludeQueryString=true}" />
        "controller" layout="${aspnet-mvc-controller}" />
        "action" layout="${aspnet-mvc-action}" />
      
    
  

  
  
    
    "Microsoft.*" maxLevel="Info" final="true" />
    "*" minlevel="Info" writeTo="ElasticSearch" />
  

 

你可能感兴趣的:(asp.net core项目 Nlog直接写入集群ElasticSearch的配置方法)