In my application I fetch some data from one of the service before the application startup using spring WebClient.
The spring WebClient is logging these data on the console. I don't want this data to be logged as it is confidential. This data needs to be fetched only on application startup due to some reasons. I want to disable these logs.
This is sample main application code
@SpringBootApplication
@ConfigurationPropertiesScan
class DemoApplication {
companion object {
@JvmStatic
fun main(args: Array<String>) {
val webClient = WebClient.builder().build()
val data = webClient.get()
.uri("http://localhost:8080/home")
.retrieve()
.bodyToMono(Response::class.java)
.block()?.data
SpringApplicationBuilder(DemoApplication::class.java).run(*args)
}
}
}
data class Response(val data: String)
And when I run this application following Response will be logged by the webClient codecs
14:10:16.944 [reactor-http-nio-1] DEBUG org.springframework.http.codec.json.Jackson2JsonDecoder - [4ef27d66] Decoded [Response(data=hello)]
14:10:16.944 [reactor-http-nio-1] DEBUG reactor.netty.resources.PooledConnectionProvider - [id: 0x9a13da08, L:/127.0.0.1:62737 - R:localhost/127.0.0.1:8080] onStateChange(GET{uri=/home, connection=PooledConnection{channel=[id: 0x9a13da08, L:/127.0.0.1:62737 - R:localhost/127.0.0.1:8080]}}, [response_completed])
I have tried disabling these logs by changing their log level to info in the application yaml as shown below but that does not work because this happens even before the application starts.
logging:
level:
org:
springframework:
web: info
http:
codec:
json: info
Does anyone have any other approach of disabling these application startup or the webClient codec logs?