倒騰一個新東西,首先是要了解基本概念,以後就是要學習如何 debug 。要否則很容易出現抓瞎的狀況。搞定這兩點剩下的就是耐心和恆心的問題了。html
通常 log 會根據不一樣的 log level 輸出不一樣的內容。若是是開發模式,通常把 log level 設置爲 debug 是和方便的。shell
Elasticsearch 的配置文件在 confg/
目錄下。
一共有兩個文件,一個是 elasticsearch.yml
,是對 Elasticsearch 自己進行配置, 好比 cluster name 之類的。
一個是 logging.yml
,用來配置 log 。json
咱們只要在 logging.yml
把 es.logger.level: INFO
改成 es.logger.level: DEBUG
便可。app
我遇到的問題是的第三方庫,對 request 作了封裝,返回缺乏我須要的信息。而 clojure 又不方便去改庫的源碼。因此果斷考慮用 Elasticsearch 的 log。curl
方法以下:elasticsearch
elasticsearch.yml
file能夠經過更改 elasticsearch.yml
達到 log request 的目的。加入如下代碼:ide
index.search.slowlog.threshold.query.debug: 0s index.search.slowlog.threshold.fetch.debug: 0s index.indexing.slowlog.threshold.index.debug: 0s
默認的 log 輸出在 logs/elasticsearch_index_indexing_slowlog.log
和 logs/elasticsearch_index_search_slowlog.log
裏。能夠經過 tail -f
進行查看。學習
順帶一提,Elasticsearch 自動按時間作了分割,大讚。fetch
配置完,咱們能夠經過 http://localhost:9200/_settings 查看咱們的配置是否成功。ui
咱們還能夠經過 HTTP API 更改設置,這樣作的好處是能夠不須要重啓 Elasticsearch 。
curl -XPUT "http://localhost:9200/_settings" -H 'Content-Type: application/json' -d' { "index.search.slowlog.threshold.query.debug": "0s", "index.search.slowlog.threshold.fetch.debug": "0s", "index.indexing.slowlog.threshold.index.debug": "0s" }'
Elasticsearch 使用起來很舒服,不管是文檔,仍是 API,都很是好用。有不少讓人眼前一亮的小細節,好比在請求里加上 `pretty' ,會有漂亮的輸出。
從這些小事能夠看出,Elasticsearch 是一款很用心的產品。
http://blog.florian-hopf.de/2...
https://www.elastic.co/guide/...