Skip to content

Dynamic logs

You can add dynamic logs directly to your application while it's running.

Once you've added the logs, you can view the output directly from the IDE.

Prerequisites

To use the plugin, make sure you have:

  • Installed the plugin in your local IntelliJ instance
  • Authenticated IntelliJ with your Lightrun account
  • Attached at least one agent to your app
  • Opened the source code file for the running application from the IDE
To add a log
  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 production.

  2. Right-click to open the IntelliJ context menu.

    Lightrun's Context Menu
  3. From the Lightrun context menu, select Log.

    The Create Log dialog opens.

    Creating a Log
  4. Complete the fields in the dialog as follows:

    • Agent

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

    • File

      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.

    • Format
      The actual log string. Use expressions such as My variable is {var}, including method invocations such as: Method value: {myMethod() + 5}.
    • Log Level
      Select one of: Debug, Info, Warning, or Error. Once configured, dynamic logs can also be filtered by this attribute.
    • Condition

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

      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.

  5. Click Advanced to configure the following additional fields:

    • Ignore quotas

      The quota (rate limit) is configured by the agent configurations. Only users with IGNORE_QUOTA role can override the agent's quota limitation, the checkbox in the Lightrun plugin is disabled for other users.

    • Expiry

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

  6. To add the log, click OK. A marker appears above the selected line.

    A New Log Entry

    Tip

    You can customize your profile picture as it appears in the marker, at gravatar.com

  7. Click Log edit -icon from the log marker to delete or edit the log configuration.

    Modifying a Log Entry

Update, edit, and delete actions

Once you've added an action, you can manipulate it by:

  • Viewing its details
  • Editing its configuration
  • Removing it
To work with existing actions

Once you create a snapshot or a metric, the relevant icon appears in the gutter of your code. When you enter a log, it is represented in line with your code. Icons for all of these options appear similar to those in the figure below.

Operation Icons
  1. Hover over the relevant icon to view summary information from its tooltip.

  2. Click the log icon or right-click any icon in the gutter to edit, delete, and view details.

    Editing an Action

Configure piping

To view data from the IDE, you must configure the routing accordingly.

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

  • App/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. In the Lightrun plugin, navigate to the right-hand sidebar:

    The Sidebar
  2. From the relevant agent, click Sidebar -icon to open the Piping menu:

    Log Piping
  3. To view Lightrun Logs and Metrics from the IDE, set either the Plugin or the Both option.

Note

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

View logs

Lightrun dynamic logs and metrics, by default, are printed into the standard logging framework. This enables them to be analysed in the context of pre-existing logs or metrics, which might provide further clues towards solving issues.

At the same time, you can see dynamic and metrics output and, from your IDE's terminal window and search and filter, as you work. To do this, first configure logs and metrics routing for each agent. Once configured, all relevant information from any Lightrun logs or metrics, which are are added to an agent, appears in the the IDE terminal.

Viewing logs and metrics from the IntelliJ Lightrun plugin

Once you've configured routing for the plugin and added at least one action to the code, dynamic logs and metrics begin updating within the Lightrun Console, in real time.

The Lightrun Console

You can control the display of logs in the IDE using any combination of the following options:

  • Use the filters at the top right of the Lightrun Console to filter the dynamic logs or metrics relevant to your investigation.
  • In the search bar at the top left, start typing to search dynamically for dynamic logs or metrics by name.
  • To free memory or remove items already viewed, click Clear.

Last update: June 19, 2022