elasticsearch - ElasticsearchRestTemplate 不打印日志
基于spring boot 2.6.6
问题
ElasticsearchRestTemplate 不打印日志 !!
原始配置
# application.yml
spring:
application:
name: boot-elasticsearch
elasticsearch:
rest:
uris: http://192.168.1.xx:9200
logging:
level:
org.springframework.data.elasticsearch.core: debug
org.springframework.data.elasticsearch.client.WIRE: TRACE
org.springframework.data.elasticsearch.client.WIRE: TRACE 本来加了这个应该会打印日志,结果什么都没有。。。
正确配置
不使用 配置文件
# 注释 配置
spring:
application:
name: boot-elasticsearch
# elasticsearch:
# rest:
# uris: http://192.168.1.17:9200
logging:
level:
org.springframework.data.elasticsearch.core: debug
org.springframework.data.elasticsearch.client.WIRE: TRACE
通过 java代码注入
@Bean(destroyMethod = "close")
public RestHighLevelClient restClient() {
ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo("192.168.1.xx:9200")
.build();
RestHighLevelClient client = RestClients.create(clientConfiguration).rest();
return client;
}
日志打印:
o.s.data.elasticsearch.client.WIRE : [65f5cae3] Sending request GET / with parameters:
o.s.data.elasticsearch.client.WIRE : [65f5cae3] Received raw response: 200 OK
o.s.data.elasticsearch.client.WIRE : [636fccb0] Sending request GET /user/_doc/1 with parameters
o.s.data.elasticsearch.client.WIRE : [636fccb0] Received raw response: 200 OK