Saturday, February 18, 2012

LoadRunner has weird logging issue. While trying to only log when in the VuGen with JIT logging set as default, I could not programatically set the log level. I finally had to contact HP support which indirectly came up with the solution. Using the code below will set the log level to brief so you can track your test script while executing it in the VuGen, when running it in the controller, your logs will only show when an error occurs.



//if running in VuGen turn on logging
int vuserid;
lr_whoami(&vuserid, NULL, NULL);

if (vuserid == -1) {

// The lr_set_debug_message() function has a non-intuitive (i.e. stupid) behaviour,
// where it will automatically set LR_MSG_CLASS_JIT_LOG_ON_ERROR if your runtime
// settings have this option enabled. You must turn off JIT log as the last step.

lr_set_debug_message(LR_MSG_CLASS_BRIEF_LOG, LR_SWITCH_ON);
lr_set_debug_message(LR_MSG_CLASS_JIT_LOG_ON_ERROR, LR_SWITCH_OFF);

lr_output_message("Running in VuGen, turn on logging.");

}

No comments: