chenggangpro / spring-cloud-gateway-plugin

Spring Cloud Gateway Extra Plugin
Apache License 2.0
174 stars 65 forks source link

add a option to disable request/response log #10

Closed abccbaandy closed 5 years ago

abccbaandy commented 5 years ago

In my case, I want log desensitization json instead raw json log.

so I need disable log from RequestLogFilter.

I try log-request: false, but it disable the whole log system.

I only need

GatewayContext gatewayContext = exchange.getAttribute(GatewayContext.CACHE_GATEWAY_CONTEXT);
chenggangpro commented 5 years ago

I just supply a simple request log ,you can custom with GlobalFilter in your own way.


Suggestion:

  1. Set log-request: false and read-request-data: true.
  2. Write your own GlobalFilter and Set Order AfterFilterOrderEnum.GATEWAY_CONTEXT_FILTER.getOrder()
  3. In your own GlobalFilter , you can custom log with GatewayContext
abccbaandy commented 5 years ago

But set log-request to false will disable everything, even GatewayContextFilter, isn't it? https://github.com/chenggangpro/spring-cloud-gateway-plugin/blob/master/src/main/java/pro/chenggang/plugin/springcloud/gateway/config/GatewayPluginConfig.java

chenggangpro commented 5 years ago

Ops,Temporary you can replace the bean GatewayContextFilter. Later today I’ll fix it.Thx for report.

chenggangpro commented 5 years ago

@abccbaandy I have deploy 1.3.1 to the maven central , You should give it few hours to accept the dependency

abccbaandy commented 5 years ago

Thx for quick fix.

But I'm sorry, I have another question now.

https://github.com/chenggangpro/spring-cloud-gateway-plugin/commit/8cccb2aa964a0b5ea7bb6bb070050c786193d4f5#diff-69f669463220f0e26dc2fc29e2889945R31 According to this commit, I need to update my config to this spring.cloud.gateway.plugin.grey.enable=true to enable GatewayContextFilter

But it will also enable those load balancer feature too, which I don't need it.

I was hope there is independent config for GatewayContextFilter ex: spring.cloud.gateway.plugin.config.enable=true

chenggangpro commented 5 years ago

My deeply apologize. I will fix it indeed.Sorry for that,my bad.

chenggangpro commented 5 years ago

@abccbaandy I just remove @CondtionOnProperties Config ,Deploy with version 1.3.2.RELEASE. Sorry for 1.3.1,My Apologize.