Capture and logging an incoming request into a Virtual Service without setting DEBUG
search cancel

Capture and logging an incoming request into a Virtual Service without setting DEBUG

book

Article ID: 368127

calendar_today

Updated On:

Products

Service Virtualization

Issue/Introduction

Incoming requests to a Virtual Service can be viewed by using "Inspection View" in the DevTest Portal. Is there a way to log the incoming request in the vse.log without setting DEBUG

Environment

Service Virtualization 10.7 Virtual Service Environment

Resolution

An easy way to log an incoming request in the vse.log is to use a script step that copies one or more of the request properties to the log file. 
For example the contents of the property lisa.vse.http.current.transaction.body can be written with the following groovy script: 
String s;
s = testExec.getStateValue("lisa.vse.http.current.transaction.body");
_logger.info( ">>>lisa.vse.http.current.transaction.body>>>" + s + "<<<"  );

This will then show up in the vse.log as: 
2024-05-16T08:13:25,197Z (18:13) [MYVS [VS_MYVS_Run]/1] INFO  com.itko.lisa.script.logger    - >>>lisa.vse.http.current.transaction.body>>><soap:Envelope>
    <soap:Body>
        <tns:data>

There is no need to set DEBUG in logging.properties as the message will show with level INFO.
Also there is no limit on the number of characters that are written.
The script can run as part of a "Scriptable Data Protocol" filter in the listener step or as a separate script step.