lr_error_message function in Loadrunner with examples

In this tutorial, will go through how to use lr_error_message function with examples

When do you use this lr_error_message?

  1. This function is used when you want to output an error to different log files in Loadrunner
  2. Use this function only for logging errors for other messaging purposes use lr_output_message or lr_log_message.
  3. The maximum file size for logging is limited to 5 KB.
  4. This function will send to output file even though logging is disabled as this is error log.
  5. Return values – if the function is successful it will return the error string in red color to the output log. If it is failed, it will return -1(negative number).
  6. When you are using this function and printing the error and also wants to fail the transaction change the settings in run time setting ->Miscellaneous -> Error Handling -> Fail open transactions on lr_error_message.
  7. You can also get the transaction response time before failing the transaction using lr_get_transaction_duration.

Output file in VuGen

You will see the message in VuGen window in red color as show in the below image.

VuGen Output Window

Controller Status Window

You can see the message in controller status window as shown in the below image.

Controller Error Tab

Controller Output Window

You can also see this message in controller output. Go to View and click on Show Output

Controller Output Window

Error Log Folder

Navigate to results and results settings, you will see the log file folder where you will see the error logs

Go to C:\Users\VJ\AppData\Local\Temp\res\log and open with notepad or notepad++

Java function is lr.error_message where as C function is lr_error_message.

Controller Log Folder

Controller Error Log File

 

Example

Action()
{
  
  char *Str1="Hello World";
  lr_error_message( "%s", Str1);

  return 0;
}

see this page for more loadrunner functions.

Leave a Comment