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 data from the plugin console, you must configure the routing accordingly.

There are three options for routing Lightrun logs:

  • Stdout - The default option. Logs are routed only to the application's standard output.
  • Plugin - Logs appear in the Lightrun Console, Management Portal, and any configured logging framework integrations. Dynamic logs are not sent to standard output.
  • Both - Logs appear in the the Lightrun Console, Management Portal, standard output, and any configured logging tool integrations.

To configure log routing in VSCode:

  1. In the Lightrun plugin, select the Agents tab.
  2. One the relevant agent, click the Agent options menu icon ....
    The AGENT OPTIONS and LOG ROUTING dropdown menu appears.

    Log routing menu

  3. Under LOG ROUTING, from the list, select the required log routing option (Stdout, Plugin, or Both).


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

Last update: January 18, 2022