lr_log_message function in Loadrunner with Examples

lr_log_message is similar to lr_output_message but this function will also print to controller or load generator log file. If you want to track order numbers or something you want write to file, you can easily do with this function and there is no need for writing any code.

In order to write to the file in controller, go to runtime settings in controller or performance center and click on enable logging and click on always send messages and log messages at the detail level of standard log. Ensure you enable this option in controller or performance center otherwise you don’t see the log file. 

The location of the log file in controller or performance center is C:\Users\UserAccount\AppData\Local\Temp\res\log

lr_log_message Example:

In this example, you can see the function writing to Vugen output file and it will also write to Controller or load generator log file.

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

  return 0;
}

OutPut:

Virtual User Script started at: 8/11/2019 11:15:36 AM
Starting action vuser_init.
Web Turbo Replay of LoadRunner 12.60.0 for Windows 10; build 971 (Aug 09 2018 11:27:13)  	[MsgId: MMSG-26983]
Run mode: HTML  	[MsgId: MMSG-26993]
Replay user agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)  	[MsgId: MMSG-26988]
Runtime Settings file: "C:\Users\softwarehour\Documents\VuGen\Scripts\SoftwareHour\\default.cfg"  	[MsgId: MMSG-27141]
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Maximum number of concurrent connections per server: 6  	[MsgId: MMSG-26989]
Starting action Action.
Hello World
Ending action Action.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.

For more examples, please see all the list of loadrunner functions with examples

 

Leave a Comment