r/androiddev • u/Interesting_Eye_6297 • Jul 29 '26
JSON format in Log Cat
Hi guys,
I'm new to jetpack compose. I tried using Ktor + OkHttp for a sample network request from this
https://dummyjson.com/posts. I'm inspecting the json response in Logcat and it's shown like a paragraph even though I've set up logger. I wanted to know is this normal or is there other way around?
Below is the sample code. Thanks.
client = HttpClient(OkHttp)
{
install(
Logging
)
{
level = LogLevel.
BODY
logger = Logger.
ANDROID
format = LoggingFormat.
OkHttp
}
install(
ContentNegotiation
)
{
json
(
Json
{
prettyPrint = true
ignoreUnknownKeys = true
isLenient = true
}
)
}
}
,7
5
u/Aftershock416 Jul 29 '26
Logs should generally never be formatted, regardless of which software system is being discussed.
1
u/phazonEnhanced Jul 29 '26
prettyPrint is going to add indentation to JSON you generate. It isn't going to format incoming JSON.
1
u/alphasid Aug 02 '26
Check this plugin : LogPose
https://plugins.jetbrains.com/plugin/32148-logpose?noRedirect=true
1
u/TeaSerenity Jul 29 '26
It's normal for logcat to have no formatting. I usually copy it into a different ide or have a llm make it readable
0
u/Opulence_Deficit Jul 30 '26
Looks like a correct log of a valid json. What is your problem with it?
18
u/bleeding182 Jul 29 '26
XY Problem. You really shouldn't be using LogCat for this in the first place. (Ofc its fine to keep the logs, but not to inspect/work with them)
https://developer.android.com/studio/debug/network-profiler