Printing the response in logs

I am using below code to print he SOAP service response, But unable to see the reponse in logs. is there any setting or preferences need to be updated?

response = WS.sendRequestAndVerify(findTestObject(‘Calculator/Addition’))

KeywordLogger log = new KeywordLogger()
log.logInfo(response.toString())

What does it look like if you turn off tree mode?

image

What does it look like in the Console?

image

Thanks for the quick response @Russ_Thomas

Changing the tree mode didnt help me…

in console its getting printed as 500 1 KB

2019-05-30 01:04:09.438 DEBUG testcase.Addition - 3: log.logInfo(response.toString())
2019-05-30 01:04:09.438 INFO c.k.katalon.core.logging.KeywordLogger - 500 1 KB

Note: I am running at test suite level and using data source

Does this below warning matters??

2019-05-30 01:04:09.437 DEBUG testcase.Addition - 2: log = new com.kms.katalon.core.logging.KeywordLogger()
2019-05-30 01:04:09.438 WARN c.k.katalon.core.logging.KeywordLogger - Please use “KeywordUtil.logInfo()” instead of “new KeywordLogger()” constructor. “KeywordLogger” is an internal API and might be changed in the future

Today? No. Tomorrow? Maybe.

I was able to get it by adding

KeywordLogger log = new KeywordLogger()
log.logInfo(response.responseBodyContent)
println(response.responseBodyContent)

@Katalon_team Dont you think there should be an default option to print the request response pairs for a test suite run??
Because i am getting error in response, now i have to look for the option to print the request

Thanks a lot I found the issue.

1 Like

Do this instead:

import com.kms.katalon.core.util.KeywordUtil

// ...

KeywordUtil.logInfo(response.responseBodyContent)

That will keep you safe from any changes the dev team might make.

Also, try this:

KeywordUtil.logInfo(response.toString())
2 Likes

Thanks Again!
response.toString() is not working. But i am to print with above one!

1 Like

import groovy.xml.XmlUtil
import com.kms.katalon.core.util.KeywordUtil

KeywordUtil.logInfo(XmlUtil.serialize(response.responseBodyContent))

pretty print XML in logviewer

Where to add this & how you fixed the error. I am not able to resolve it. Your help would be appreciated.

Gives me Error
Ambiguous method overloading for method groovy.xml.XmlUtil#serialize.
Cannot resolve which method to invoke for [null] due to overlapping prototypes between: