How to log information in VS to see it in VSE log?

Document ID : KB000112450
Last Modified Date : 29/08/2018
Show Technical Document Details
Introduction:
Sometimes, we need to find out some information from the VS which we can't see it in inspection view.
Question:
How to log information in VS to see it in VSE log?
Environment:
Al suported DevTest environments.
Answer:
To log the information in the VSE logs, add the code in a scripted assertion in the VSM steps. For example, see the below code
------- 
_logger.info(" Service = {}, Step = {} And Data is: {}", 
"My Virtual Service Name Here", 
testExec.getStateValue( "LISA_LAST_STEP" ), 
testExec.getStateValue("accountNumber") ); 
// log additional values here 
_logger.info(" Getting List of Virtual Services"); 
return true;
----

VSE log will show information like below based on the above code
----
Service = {"My Virtual Service Name Here"}, Step = {the value of "testExec.getStateValue( "LISA_LAST_STEP" );" } And Data is: {the value of "testExec.getStateValue("accountNumber") ); "}"
Getting List of Virtual Services
---

Note: You can always "return true;" in the code and do the assertion logic as "If False to Fail" (which will  never happen.