Share this page

# lr_log_message

Sends a message to the log.

    int lr_log_message( char *format, exp1, exp2,...expn.);

Alphabetical Listing - C Language Utility Functions

## Arguments

Name | Comments
--- | ---
format C Language | A formatted string to send to the log file. If it is a literal string, enclose it with quotation marks. Use the standard Message Formatting that is available for printf to set the format for the expressions you want to print.
exp1, exp2,.. expn C Language | The expressions (variables) to be formatted and printed.
message Object oriented languages | A string containing the message to send to the log. See and Java String Arguments.

The lr_log_message function sends a message to the Vuser or agent log file (depending on the application), and not to the output window. You can use this function for debugging by sending error or other informational messages to the log file.

You can avoid overloading the network by using this function to send messages to the log file rather than sending messages to the Output window (with lr_error_message or lr_output_message). In a standalone program such as VuGen, lr_log_message sends the message to the viewer and output.txt.

To send a message to the output file, you must enable logging in the runtime settings, and select Always send messages. If you select Send messages only when an error occurs, there is no output from this function. lr_set_debug_message calls can also affect the output.

In the Vuser Execution log, this function does not list the location and line number from where the message was issued. To issue a message with those details, use lr_output_message.

#### statement | #### Output
--- | ---
lr_log_message("a message") | a message
lr_output_message("message"); | Action(4): message

## Return Values

If this function succeeds, it returns the length of the message that was sent. If the function fails, it returns a negative number.

## Parameterization

You cannot use standard parameterization for any arguments in this function.

See Also

## Example

In the following example, lr_log_message sends a message to the log file if the connection to the server fails.

    char* abort="aborting...";
    ...
    if (init() < 0) {
        lr_log_message ("login failed: %s", abort);}
       return(0);
    }

In the next example, an `Iteration Number` type parameter called `"iteration`" was defined in VuGen. The lr_log_message function sends a message indicating the current iteration number.

    lr_log_message( "We are on iteration #%s", lr_eval_string( "{iteration}" ) );

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: