Skip to content

Dynamic logs

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

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

Prerequisites

To use the plugin, make sure:

  • You've attached at least one agent to your app
  • You install the plugin in your local IntelliJ instance)
  • You authenticate IntelliJ with your Lightrun accountß
  • Make sure you have access to the server where the application with the agent is running.
  • Be sure to open the source code file for the running application from the IDE.
To add a log
  1. Go to the line of your source code at which you'd like to insert the log.

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

    Context Menu -half

  3. Open the Lightrun context menu:

    Context Menu -half

  4. Select Log from the Lightrun context menu.

    The Create Log dialog opens:

    Create Log -third

  5. Complete the fields in the dialog as follows:

    • Agent

      bind the action to a specific agent or tag from the available options in this dropdown list

    • File

      this is the source code file into which you're inserting the action; default is to the source code file from which you're already 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 - Debug, Info, Warning or Error; once configured, dynamic logs can also be filtered by this attribute
    • Condition

      an expression that limits the action; this is the condition of an if statement used to limit the execution of the action

      !!! example myVar % 7 == 0 limits the log so it only prints for variables that are divisible by 7

  6. Click Advanced to configure the following additional fields:

    • Ignore quotas

      the quota (rate limit) is configured in the agent configuration file. Ignore Quotas defaults to off. Only users assigned the IGNORE-QUOTA role can perform this configuration; the checkbox is disabled for other users.

    • Expiry

      the time after which the action ceases to track code behavior and is automatically disabled; defaults to 1 hour

  7. Click OK to add the log. A marker is also added to the area above the line:

    Log Entry -third

    Tip

    Customize your profile picture as it appears in the marker at gravatar.com

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

    Log Entry -third

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 exising actions

Once you create snapshot or 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 the similar to the following:

Plugin gutter -quarter

  1. Hover over the relevant icon to read summary information from its tooltip.

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

    Edit actions -quarter

Configure piping

Data output is sent to your IDE, the CLI, the web interface, or your integrated logging tools depending on how you've configured piping.

By default, all output is piped to the web interface in the web interface. To view data from the IDE, you must first configure the piping accordingly.

There are three levels of log piping:

  • App - the dynamic logs appear only in the Lightrun web interface, as they do by default.
  • Plugin - that dynamic logs won't appear in the web interface. Instead they appear in the Lightrun Console of your IDE, the CLI, or your integrated logging tools.
  • Both - that dynamic logs wll appear both in the web interface and in any integrations you're using.
To configure piping
  1. Navigate to the Lightrun right-hand sidebar:

    Sidebar -quarter

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

    Log Piping -ten

  3. Set the Plugin or the Both option to view dynamic logs from the IDE.

Note

In order to pipe the dynamic logs they need to go from the agent to the Management server and to the plugin. This process is batched so dynamic logs appear in batches and with some delay.

View logs

Lightrun dynamic logs and metrics are normally printed into the standard logging framework. This is quite valuable as dynamic logs can be seen in the context of pre-existing log statements, which might provide further clues towards solving issues.

At the same time, a developer might want to see the log output and search and filter directly from the IDE as they work. To do this, first configure log piping per-agent. Once configured, all relevant information from any Lightrun actions that are added to the agents appears in the developers' consoles.

To view log data from IntelliJ

Once you configure piping for the plugin and add at least one action to the code, dynamic logs and metrics start updating in real time in the Lightrun Console at the bottom sidebar in IntelliJ:

Lightrun Console

  1. Use the filters at the top right of the Console data to filter for the dynamic logs relevant to your investigation.

  2. Use the search bar at the top left to start typing and search dynamically for dynamic logs by name.

  3. To free memory or remove items already viewed, click Clear.


Last update: May 6, 2021