Skip to content

Dynamic Logs

From the Lightrun plugin for VSCode, you can add dynamic logs directly to your running application.


To use the plugin, make sure you have:

  • Attached an agent to your application
  • Installed the plugin in your local VSCode instance
  • Authenticated the VSCode plugin against your Lightrun account
  • The source code file for your running application is opened in VSCode

Adding logs

To add logs, you must open the Insert a Log form and enter log parameters.

Opening the Insert a Log form

Select either of the following methods:

A. Through either the Agents or Tags tab
B. From a code line in the VSCode editor

A. Agents or Tags method:

  1. From either the Agents or Tags tab, select an agent or tag and click the Add Action icon Add Action button.
    The ACTIONS and METRICS menu opens.
    Add Action button
  2. Under ACTIONS, select Log.
    The Insert a Log form opens.
    Create Log

B. Code line method:

  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 VSCode context menu.
    VSCode context menu
  3. From the VSCode context menu, click Lightrun....
    The VSCode Command Palette opens with a list of Lightrun plugin options.
    Lightrun context menu
  4. From the Command Palette, select Insert a Log
    The Insert a Log form opens.
    Insert a log form

Entering Log parameters

  1. Complete the fields in the Insert a Log form, as follows:

    • TARGET

      From the available options in the dropdown list, bind the action to a specific agent or tag.


      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.


      Clicking the Get filename & line Get filename & line icon icon automatically loads the file name and line number at which the cursor currently is positioned within the VSCode editor.


      The actual log string. Use expressions such as My variable is {var}, including method invocations such as: Method value: {myMethod() + 5}.


      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.


      The condition of an if statement, used to limit the execution of the action.


      The condition myVar % 7 == 0 limits the action (log, snapshot, metric) output so that it only prints for variables that are divisible by 7.


      The time after which the action ceases to track code behavior and is automatically disabled; default = 1 hour.

  2. Click Create to add the Log.
    Upon log creation:

    • In the VSCode editor, the Log icon icon appears next to the selected code line.
    • In the Lightrun plugin, (depending on the target) the target agent or tag is expanded with the new log action appearing under it.

      Log entry

Disabling, deleting, or editing a log

Disabling a log

To temporarily pause logging:

  1. From the list under Actions bar, hover your cursor over the relevant log.
    A toggle switch appears.
    Action toggle switch
  2. Click the toggle switch from blue (on) to grey (off).
  3. To resume logging, click the toggle back to blue.

Deleting a log

To delete a log, next to the Action identifier, click the menu icon ... and select Delete from the ACTION OPTIONS menu.
Action Options menu

Viewing and editing a log configuration

To view and edit a log configuration:

  1. from the ACTION OPTIONS menu, select Details.
    The Log details pane appears.
    Log details pane
  2. Next to Details row, click the edit icon Edit icon.
    The Edit a Log form opens.
  3. In the Edit a Log form, enter your new log configuration data.

Viewing logs output

Lightrun agent logs can be routed to the VSCode Lightrun Console, the app's standard output (Stdout), or your integrated logging tools, depending on how you have configured routing and any integrations.

To view Lightrun Logs and Metrics data from VSCode, you must configure the routing accordingly.

There are three levels of routing for output from Lightrun dynamic logs and metrics:

  • Stdout - Output appears only in the application's standard output.
  • Plugin - Output appears in the Lightrun Management Portal, Lightrun Console, and integrations.
  • Both - Output appears in the Lightrun Management Portal, Lightrun Console, integrations, and standard output.

To configure routing:

  1. From the Lightrun sidebar, choose either of the following methods.
  2. Under the Agents tab, for the relevant agent, click the More options icon.
    The AGENT OPTIONS menu opens.
    Agent options menu
  3. Choose either of the following two methods:

    Method A:
    From the Agent Options menu, under LOG ROUTING, select an options from Stdout, Plugin, or Both.

    Method B:
    1. From the Agent Options menu, under AGENT OPTIONS, select Details.
    The Agent Details window opens, with the LOG ROUTING options menu.

    Agent options menu
    2. From LOG ROUTING, select an option from Both, App only, or Plugin only.


Dynamic Logs and Metrics are sent from the agent to the plugin via the Lightrun server. As this process is batched, output may appear with a slight delay.

Last update: June 19, 2022