List

An essential part of the performance testing projects is developing scripts which simulate the user actions (VUser scripts in LoadRunner). In the scripting phase, an important part is debugging of the scripts in case you run into some issues.

Mostly people talk about enabling the Extended Log feature in the Run-time Settings GUI, and then in turn checking Parameter Substitution and/or Data Returned by the Server and/or Advanced Trace check boxes, as per the requirements. This is a good approach, except that whatever options you select will be applied to the complete script. This means that although you know that, the problem is with 5th step and you want to debug that step, you have to see the Extended Log for the previous steps as well.

We can achieve Extended Logging in LoadRunner in a very simple and flexible way, through scripting. LoadRunner has an in-built function with the name lr_set_debug_message(). This function takes two arguments, first being the flag (or flags separated by “|” operator) indicating the extent of logging., and the second to turn it on or off. The flags can be set with the Constant text flags or corresponding digits. For example, the following function chooses Extended Log with Full Trace and switches it to on.

lr_set_debug_message (LR_MSG_CLASS_EXTENDED_LOG | LR_MSG_CLASS_FULL_TRACE, LR_SWITCH_ON );


It can as well be put as:

lr_set_debug_message16|8, 1); (where 16 and 8 stand for the corresponding constant text flags and 1 stands for ON.

If you want to enable all kinds of logging for only a particular step, simply wrap the transaction step(s), as follows:

lr_set_debug_message(16|8|4|2, 1); // Logging on
/* The transaction steps go here */
lr_set_debug_message(16|8|4|2, 0); // Logging off

I found this a very useful tool during debugging phase. I hope you enjoy it too. For further details, you can refer the Help file in VUGen.

Rahul Verma

www.testingperspective.com

3 Responses to “Selective Logging for effective debugging in LoadRunner”

  1. somaraju

    Hi Rahul,
    This might be very helpful one. Please provide us concepts like this which can be very useful.

    regards,
    mahesh somaraju

  2. Rahul Verma

    Hi Somaraju,

    I am happy to hear that the information provided in this post has helped you.

    Right now, as you can see, I am busy in putting a series of posts on “Schools of Testing”. There is a lot of ground work which is needed for that. After this series, you can be sure of reading some really good tips for performance testers.

    Keep visiting and sharing views.

    Regards,
    Rahul Verma.

  3. Santhosh

    Hi Rahul,
    Really useful command. :)

Leave a Reply

Your email address will not be published. Required fields are marked *