Hi all, when using Ktor, how can i log `request Bo...
# ktor
b
Hi all, when using Ktor, how can i log
request Body
?
I am currently using
Copy code
HttpClient {
        install(Logging) {
            level = LogLevel.ALL
        }
}
It is printing
response Body
not request
body
a
Hey. Using the following code I can see the lines about request body in the log:
Copy code
2022-01-26 13:45:54.467 [main] INFO  io.ktor.client.HttpClient - BODY START
2022-01-26 13:45:54.467 [main] INFO  io.ktor.client.HttpClient - My Body
2022-01-26 13:45:54.467 [main] INFO  io.ktor.client.HttpClient - BODY END
Copy code
suspend fun main(): Unit = coroutineScope {
    val client = HttpClient(Apache) {
        install(Logging) {
            level = LogLevel.ALL
        }
    }

    val r = <http://client.post|client.post><String>("<https://httpbin.org/post>") {
        body = "My Body"
    }
    println(r)
}
1
b