Skip to content
Nebula Logger Docs (Blume Demo)
Esc
navigateopen⌘Jpreview
On this page

For Developers

Apex and Lightning Web Component quick starts, fluent logging API, and save methods.

Nebula Logger gives Apex and Lightning Web Component developers a single, fluent logging API instead of scattered System.debug() calls that disappear the moment the transaction ends.

Apex quick start

Logger.error('Add log entry using Nebula Logger with logging level == ERROR');
Logger.warn('Add log entry using Nebula Logger with logging level == WARN');
Logger.info('Add log entry using Nebula Logger with logging level == INFO');
Logger.debug('Add log entry using Nebula Logger with logging level == DEBUG');
Logger.fine('Add log entry using Nebula Logger with logging level == FINE');
Logger.finer('Add log entry using Nebula Logger with logging level == FINER');
Logger.finest('Add log entry using Nebula Logger with logging level == FINEST');
Logger.saveLog();

Each call becomes one Log__c record with related LogEntry__c records — queryable, reportable, and dashboard-able like any other Salesforce data.

Lightning components

import { getLogger } from 'c/logger';

export default class LoggerDemo extends LightningElement {
  logger = getLogger();

  connectedCallback() {
    this.logger.info('Hello, world');
    this.logger.saveLog();
  }
}
<aura:component implements="force:appHostable">
  <c:logger aura:id="logger" />
</aura:component>
const logger = component.find('logger');
logger.error('Hello, world!').addTag('tag');
logger.saveLog();

Fluent interface

Methods chain, so you can attach records, tags, and custom fields in one line:

Logger.debug('my string').setRecord(currentUser);
Logger.debug('message').addTag('important');

Save methods

Logging shouldn’t slow down your transaction. Nebula Logger supports four ways to persist logs, controlled per-transaction or globally:

Logger.setSaveMethod(Logger.SaveMethod.EVENT_BUS);
// Publishes LogEntryEvent__e platform events — fully async, no governor limit impact
Logger.setSaveMethod(Logger.SaveMethod.QUEUEABLE);
// Defers processing to an async queueable job
Logger.setSaveMethod(Logger.SaveMethod.REST);
// Synchronous callout using the current session ID
Logger.setSaveMethod(Logger.SaveMethod.SYNCHRONOUS_DML);
// Immediate Log__c / LogEntry__c creation in the current transaction

Transaction controls

  • Logger.suspendSaving() / Logger.resumeSaving() — pause and resume persistence mid-transaction
  • Logger.flushBuffer() — discard unsaved entries entirely
  • Logger.setParentLogTransactionId(String) — stitch batch and queueable jobs back to the log that kicked them off

For ISVs: optional dependency

Package developers can call Nebula Logger without a hard dependency, using the Callable interface:

Type nebulaLoggerType = Type.forName('Nebula', 'CallableLogger') ?? Type.forName('CallableLogger');
Callable nebulaLoggerInstance = (Callable) nebulaLoggerType?.newInstance();

Was this page helpful?