anyone log the java http client? I tried adding th...
# community-support
c
anyone log the java http client? I tried adding this, but I still don't get logs for it
Copy code
tasks.withType<Test>().configureEach {
  systemProperty("jdk.httpclient.HttpClient.log", "all")
}
v
I think it should work. Maybe you did not configure the logging accordingly? It lands in a System Logger on level INFO.
c
maybe? ... maybe I'm not redirecting the logger correctly... or rather that isn't as autodetected as I'd think it is
wait... info
I might have it disabled... why would anyone make http tracing info
no, I have the root logger set to info
v
root logger of what?
I mean which logging backend
c
log4j, and I'd hope that by adding log4j-jul that it'd auto direct jul to log4j, but I haven't actually double checked that spring boot is doing that yet
v
That's for jul, but System logger is jpl
c
jpl
?
v
And for jul you indeed need to set one system property before any jul class is touched, so the very first thing you do in your main method. No idea whether spring boot has something for that
You need
log4j-jpl
for those loggers
Java Platform Logging
jul is the stuff in
java.util.logging
c
didn't know that was a thing...
v
Added in Java 9 iirc
And iirc JPL should by default forward to JUL. But if you did not set the necessary system property for JUL capturing, you anyway miss all JUL logs.
c
lovely
Copy code
tasks.withType<Test>().configureEach {
  systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")
  systemProperty("jdk.httpclient.HttpClient.log", "all")
}
nope... 😕
Copy code
logging.level.root = trace
v
Did you also add
log4j-jpl
?
c
yeah
Copy code
org.apache.logging.log4j:log4j-api:2.21.1=runtimeClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath
org.apache.logging.log4j:log4j-api:2.23.1=spotbugs
org.apache.logging.log4j:log4j-core:2.21.1=runtimeClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath
org.apache.logging.log4j:log4j-core:2.23.1=spotbugs
org.apache.logging.log4j:log4j-jpl:2.21.1=testRuntimeClasspath
org.apache.logging.log4j:log4j-jul:2.21.1=runtimeClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath
org.apache.logging.log4j:log4j-slf4j2-impl:2.21.1=runtimeClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath
I think I just got it
👌 1
v
What was it?
c
narrowing it...
probably a number of things
well.. for one it looks like
application.properties
might not set this early enough
Copy code
@TestPropertySource(properties = { "logging.level.jdk=info" })
no, maybe it just doesn't like me using jdk.internal
looks like the minimum is
Copy code
tasks.withType<Test>().configureEach {
  systemProperty("jdk.httpclient.HttpClient.log", "all")
}
add
log4j-jpl
set this regardless of what the root logger is set to
Copy code
logging.level.jdk=info
👌 1
I wrote an answer for other people https://stackoverflow.com/a/78518673/206466
👌 1
and created a spring boot bug to make some improvements to docs and maybe code https://github.com/spring-projects/spring-boot/issues/40872
👌 1