Share this page

# lr.log_message

Sends a message to the log.

    int lr.log_message( String message );

Message Functions | Java Syntax

## 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.

## Examples

In the following examples, lr.log_message function sends messages to the log files.

### Example 1 - Send a simple message

    lr.log_message("Accessing Talk Forum ORB...");

### Example 2 - Send strings, longs, and other data types

Copy code

    String str = "Test";
    long lg = 100;
    lr.log_message("The value of str = " + str + ".");
    lr.log_message("The value of lg is " + lg + "." );

### Example3 - Send the output of a function call

    lr.log_message("Chat Population = " + orChatForum.count() );

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