Skip to content

Work with Lightrun Dynamic Logs in the VS Code IDE

Prerequisites

To use the plugin, ensure that:

  1. An agent is attached your application.
  2. The plugin is installed in your local VS Code instance.
  3. The Plugin ia authentication against your Lightrun account.
  4. The source code file for your running application is opened in VS Code.

From the Lightrun plugin for VS Code, you can:

Add a Dynamic Log

Note

From version 1.58, the Insert a Log option from the list has been renamed to Add Log.

  1. To add a log, select one of these methods:

    • From the Agents or Tags tab.

      1. Open the Lightrun sidebar in VS Code.
      2. Go to the Agents or Tags tab and select an agent or tag.
      3. Click the Add Action icon.

        Add Action button --icon

      4. Select Add Log.

        The Insert a Log dialog opens.

        Create Log --quarter

    • Directly from the Code line:

      1. Go to the line in your application source code where you'd like to insert the log. Make sure to use the source code version currently deployed to your remote app (where the agent is attached).
      2. Right-click to open the VS Code context menu.
        VS Code context menu --quarter

      3. From the VS Code context menu, click Lightrun.
        The VS Code Command Palette opens with a list of Lightrun plugin options.
        Lightrun context menu

      4. From the Command Palette, select Add Log.

        The Insert a Log dialog opens.

        Add log dialog

  2. Set log parameters:

    Enter the parameters in the Insert a Log dialog, as follows:

    Fields Description
    Source From the available options in the dropdown list, bind the action to a specific agent, tag, or custom source.
    Click the Custom Source icon --icon icon to create a new custom source.
    Filename & line The source code file into which you're inserting the action. The default path is to the source code file from which you're currently working.
    Log message The actual log string. Use expressions such as My variable is {var}, including method invocations such as: Method value: {myMethod() + 5}.
    Log Level Select an appropriate log level: INFO, ERROR, DEBUG, WARN.
    Once configured, logs can also be filtered by the LOG LEVEL attribute in the Lightrun console.
    Condition The condition of an if statement, used to limit the execution of the action.
    For example, The condition myVar % 7 == 0 limits the action (log, snapshot, metric) output so that it only prints for variables that are divisible by 7.
    Lifetime The time after which the action ceases to track code behavior and is automatically disabled; default = 1 hour.
    Target Select your preferred action output taget. You can pick either:
    - Stdout - Logs are routed only to your application's standard output.
    - Plugin - Logs appear in the Lightrun Console, the Lightrun Management Portal, and configured integrations.
    or both options at once.
  3. Click Create to insert the dynamic log into your code.

Manage logs

You can perform the following tasks when workint with logs.

View a Dynamic Log

  • In the VS Code editor, a Log icon --icon icon will appear next to the selected code line.
    A new log action will appear under the selected source (agent or tag) in the Lightrun sidebar.

    Log entry

You can disable, delete, or edit a log directly in your IDE.

Edit Dynamic Log settings

  1. Click the menu icon ... next to the relevant log in the Lightrun sidebar.

    Action Options menu

  2. Select Edit from the menu that appears to open the Edit a Log dialog.

    The Edit a Log dialog is displayed.

    Edit a log dialog --quarter

  3. Edit your log configuration data in the Edit a Log dialog.

Duplicate a Dynamic Log

  1. Hover your cursor over the relevant log in the Lightrun sidebar.
  2. Right-click and select Duplicate.

    Duplicate log

  3. Go to the selected destination and right-click and select Duplicate.

Copy and paste a Dynamic Log

  1. Go to the line in your application source that contains the log to be copied. Make sure to use the source code version currently deployed to your remote app (where the agent is attached).

  2. Right-click to open the VS Code context menu.

  3. From the VS Code context menu, click Lightrun.

    The VS Code Command Palette opens with a list of Lightrun plugin options.

  4. From the Command Palette, select Copy Action.

    Lightrun context menu

  5. Go to the line inyour applicationsource code where you'd like to paste the copied log.

    Lightrun context menu

Disable a Dynamic Log

  1. Hover your cursor over the relevant log in the Lightrun sidebar.
    A toggle switch should appear.
    Action toggle switch
  2. Click the toggle to switch from blue (on) to grey (off).
  3. To resume logging, click the toggle back to blue.

Delete a Dynamic Log

  1. Click the menu icon ... next to the log and click Delete

    Action Options menu --quarter


Last update: June 19, 2025