Service Virtualization

  • 1.  Customize logging of VSE logs using log4j

    Posted Mar 08, 2019 05:08 AM

    Hi All,

     

    I want to log few property values in the VSE logs so that I have a track of the request response payloads specifically during Live Invocation. Currently the data which is getting logged is mostly INFO  - Inbound Request..attributes and respective values, however need the complete request payloads and Live Invocation Step responses as well. Tried modifying the logging.properties file with the properties given in the DevTest documentation site but nothing helped. 

    Kindly suggest, how I can log certain property values in the VSE logs in real time using log4j.

     

     

    Thanks & Regards,

    SAIKAT GHOSH 



  • 2.  Re: Customize logging of VSE logs using log4j

    Broadcom Employee
    Posted Mar 11, 2019 01:01 AM

    Hi Saikat,

           If incoming request stored in a Devtest property, you can add a scriptable data protocol filter and use below logic to log content in vse log file. 

     

        String requestString = testExce.getStateValue("my_property");

        logger.log(LOG_LEVEL.INFO, "Incoming request is: " + requestString); 

     

    Thanks & Regards

    Srikanth Gajawada



  • 3.  Re: Customize logging of VSE logs using log4j

    Posted Mar 11, 2019 12:44 PM

    +1

    Also look at DevTest 8.0 - Scripting Guide - V1.1.pdf  page 19 for the injected reference to the "_logger".

    // a simple display when logging.properties is set to INFO mode 

    _logger.info("message");

     

    // a simple display with a property value

    _logger.info("<<< message is: {}", testExec.getStateValue("someProp");

             

    // or a more complex display substituting property values

    _logger.info("<<< message X: {} contains Y: {}",

                 testExec.getStateValue("propForX"),

                 testExec.getStateValue("propForY") ); 

    Where { } and { } are placeholders for the values associated with someProp, propForX and propForY, respectively.  

    Overloads are separated by a comma ( , ) as can be seen in the third example.

    _logger.info("msg");  - displays in the log when logging.properties is set to INFO

    _logger.debug("msg"); - displays in the log when logging.properties is set to DEBUG

    _logger.warn("msg");   - displays in the log when logging.properties is set to WARN



  • 4.  Re: Customize logging of VSE logs using log4j

    Posted Mar 12, 2019 05:33 AM

    Hi Srikanth,

     

    The solution you suggested is not working as “logger.log…” is throwing an error while parsing in Scriptable Data Protocol. I tried jnesmith suggestion as well, but can’t see the details getting logged in any of the log file (vse.log, vse_matches.log, <specific virtual service name>.log). Can we have a quick call on this?

     

    Regards,

    SAIKAT GHOSH



  • 5.  Re: Customize logging of VSE logs using log4j

    Posted Mar 13, 2019 07:01 AM

    I do not work for CA Support so I am unable to take a call.

    The _logger.info option is specific to where the service is running.  If running in Workstation, look in the Workstation.log. If running a virtual service in VSE, the logging occurs into the vse.log unless an admin is redirecting the output somewhere else.

    If you don't see the logs, double check to ensure that you have no typos in the Script.  An exception may be preventing you from seeing something.