将Azure应用服务日志连接到ELK

时间:2018-08-08 13:13:10

标签: azure logstash elastic-stack

我需要使用ELK堆栈可视化我的Azure应用程序服务的日志和错误日志。如何连接这些logstash。如何将我的应用程序服务日志发送到logstash。

1 个答案:

答案 0 :(得分:0)

使用NLog(https://nlog-project.org/

 <?xml version="1.0" encoding="utf-8"?>

  <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xsi:schemaLocation="NLog NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true"
      internalLogFile="internal.nlog"
      throwExceptions="true"
      throwConfigExceptions="true"
      internalLogLevel="Debug">

    <extensions>
        <add assembly="NLog.StructuredLogging.Json" />
    </extensions>

    <targets>
        <target xsi:type="Console" name="console" layout="${structuredlogging.json}" />

        <!--<target name="logstash" xsi:type="BufferingWrapper" flushTimeout="5000">-->
        <target name="logstash" xsi:type="Network" layout="${structuredlogging.json}" address="elasticsearch:5443" />
        <!--</target>-->
    </targets>

    <rules>
        <logger name="*" writeTo="logstash" />
        <logger name="*" minlevel="Trace" writeTo="console" />
    </rules>
</nlog>