Skip to content

Dynamic Logs


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 insert a Dynamic Log into your code
  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.
  3. From the Lightrun context menu, select Log. Context Menu -half The Create Log dialog should appear similar to the following image. Create Log -half
  4. Complete the fields in the 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 Create Custom Source 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.
    Format The actual log string. Use expressions such as My variable is {var}, including method invocations such as: Method value: {myMethod() + 5}.
    Targets 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.
    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.
  5. Click Advanced to configure the following additional fields:

    Fields Description
    Ignore Quota The quota (rate limit) is configured by the agent configurations.
    Only users with IGNORE_QUOTA role can override an agent's quota limitation, the IGNORE_QUOTA checkbox is disabled for other users.
    Expiry The time after which the action ceases to track code behavior and is automatically disabled; default = 1 hour.
    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.
  6. Click Save to add the log to your code.

Once a log action has been inserted into your code, a log marker should appear on the code line where the action was added.

Log marker --half

Right-click on the log marker to view more information about the log.

Log marker --half

Click the log marker to edit or delete the log action.

Log delete --half

View logs

Lightrun dynamic logs and metrics, by default, are printed into the application’s standard output(Stdout). This process enables them to be analyzed in the context of pre-existing logs or metrics, which might provide further clues towards solving issues.

At the same time, you can also configure your action target to Plugin. This configuration lets you view your dynamic logs and metrics output directly in your IDE through the Lightrun Console, the Lightrun Management Portal, and third-party integrated apps like Slack or Prometheus.

Viewing logs and metrics from the IntelliJ Lightrun plugin

Once you've configured your action target to Plugin and added at least one dynamic log or metric to your code, the Lightrun Console should display real-time output from the added dynamic log or metric.

The Lightrun Console
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: May 29, 2023