1.ELK搭建
關於ELK環境搭建在之前的博客都已經提到了。
2.項目示例
2.1添加依賴
2.2在src/main.resources新建logback-spring.xml,內容如下:
2.3新建bootstrap.properties添加如下內容
由於使用了自定義的logback-spring.xml,並且該文件中含有變量(springAppName),spring.application.name屬性必須在bootstrap.properties中設置。
2.4Logstash配置文件,命名為logstash.conf(E:\soft\logstash-6.3.2\bin 在安裝目錄的bin目錄下新建logstash.conf),具體配置如下
2.4啟動注冊中心,服務消費,服務提供者,elasticsearch,elasticsearch-head,logstash,kibana
elasticsearch-head啟動頁面:
kibana界面
通過消費者,訪問服務提供者。可以看到追蹤日志在不斷的增加。
微信公眾號