Skip to content

Plugin: Nebula Logger

Jason Siders edited this page Aug 19, 2025 · 8 revisions

This plugin leverages the Plugin Framework to automatically logs details about your DML and SOQL operations, via Nebula Logger.

Nebula Logger is a popular logging framework for Salesforce. Like Apex Database Layer, it's free, and open-source.

Getting Started

Prerequisites

To use this plugin, you must have the most recent version of Apex Database Layer and Nebula Logger installed.

Installation

If you're using both the latest & unmanaged versions of Apex Database Layer and Nebula Logger installed, you may install this plugin as an unlocked package.

First, locate the latest version of the plugin package, called nebula-logger-plugin@latest in sfdx-project.json:

sf package install --package <<package_version_id>> --wait 10

⚠️ Note: If you are using a managed version of Apex Database Layer and/or Nebula Logger, you won't be able to formally install the package. Instead, manually copy the contents of these two Apex Classes in your desired environment:

Setup

Once installed, navigate to Setup > Custom Metadata > Database Layer Settings. If a record already exists, use that record. Else, create a new record, called "Default".

Set the Custom Metadata record's DML: Pre & Post Processor and SOQL: Pre & Post Processor fields to be the name of the Apex class: DatabaseLayerNebulaLoggerAdapter:

image

Note: Once configured, this custom metadata record won't be altered by upgrading the Apex Database Layer package, or the plugin package itself.


Usage

Whenever a DML or SOQL operation runs, the plugin will log the details of those operations to Nebula Logger. This results in log entries with the apex-database-layer Log Entry Tag.

DML Logging

Just before a DML operation is processed, the plugin will issue a FINEST log entry summarizing the action that's about to take place.

  • The Dml.Request is serialized and shown in the message body
  • The records being operated on are shown in the Related Records tab
image image

After a DML operation is processed, the plugin issues another FINEST log entry summarizing the action that took place.

  • The Dml.Request is serialized and shown in the message body
  • The records that were operated on are shown in the Related Records tab
  • The relevant database result objects (ex., Database.SaveResult) are shown in the Related Records tab
image image

If an exception is thrown during a DML operation, an ERROR log entry is issued:

  • The Exception message is shown in the message body
  • The Dml.Request is serialized and shown in the message body
  • The records that were operated on are shown in the Related Records tab
image

SOQL Logging

Just before a SOQL operation is processed, the plugin issues a FINEST log entry summarizing the query about to take place:

  • The text of the query is available in the message body
image

After a SOQL operation is processed, the plugin issues another FINEST log entry summarizing the query and its results:

  • The text of the query is available in the message body
  • The resulting SObject records are available in the Related Records tab
    • Note: Other query operations (ex., getCursor, countQuery) that do not output SObjects will be printed in the message body instead
image image

If an exception is thrown during a SOQL operation, an ERROR log entry is issued:

  • The text of the query is available in the message body
  • The Exception message is shown in the message body
image

Considerations

MockSoql: Additional query logs for non-standard SOQL operations

Many MockSoql query operations use the query method as the basis for building mock results. This may result in additional logs being issued.

For example, MockSoql.getQueryLocator calls MockSoql.query to generate the list of records to be returned, and then wraps the results in a Soql.QueryLocator. In this scenario, the plugin issues 4 FINEST logs: one before/after MockSoql.getQueryLocator, and one before/after MockSoql.query.

Clone this wiki locally