-
-
Notifications
You must be signed in to change notification settings - Fork 180
Logging in Components
For lightning component developers, the logger
lwc provides very similar functionality that is offered in Apex. Simply embed the logger
lwc in your component, and call the desired logging methods within your code.
// For lwc, retrieve logger from your component's template
const logger = this.template.querySelector("c-logger");
logger.error("Hello, world!").addTag("some important tag");
logger.warn("Hello, world!");
logger.info("Hello, world!");
logger.debug("Hello, world!");
logger.fine("Hello, world!");
logger.finer("Hello, world!");
logger.finest("Hello, world!");
logger.saveLog();
// For aura, retrieve logger from your component's markup
const logger = component.find("logger");
logger.error("Hello, world!").addTag("some important tag");
logger.warn("Hello, world!");
logger.info("Hello, world!");
logger.debug("Hello, world!");
logger.fine("Hello, world!");
logger.finer("Hello, world!");
logger.finest("Hello, world!");
logger.saveLog();
For lightning component developers, the included logger
lwc can be used in other lwc & aura components for frontend logging. Similar to Logger
and LogEntryBuilder
Apex classes, the lwc has both logger
and logEntryBuilder
classes. This provides a fluent API for javascript developers so they can chain the method calls.
Once you've incorporated logger
into your lightning components, you can see your LogEntry__c
records using the included list view "All Component Log Entries'.
Each LogEntry__c
record automatically stores the component's type ('Aura' or 'LWC'), the component name, and the component function that called logger
. This information is shown in the section "Lightning Component Information"
To use the logger component, it has to be added to your lwc's markup:
<template>
<c-logger></c-logger>
<div>My component</div>
</template>
Once you've added logger to your markup, you can call it in your lwc's controller:
import { LightningElement } from "lwc";
export default class LoggerDemo extends LightningElement {
logSomeStuff() {
const logger = this.template.querySelector("c-logger");
logger.error("Hello, world!").addTag("some important tag");
logger.warn("Hello, world!");
logger.info("Hello, world!");
logger.debug("Hello, world!");
logger.fine("Hello, world!");
logger.finer("Hello, world!");
logger.finest("Hello, world!");
logger.saveLog();
}
}
To use the logger component, it has to be added to your aura component's markup:
<aura:component implements="force:appHostable">
<c:logger aura:id="logger" />
<div>My component</div>
</aura:component>
Once you've added logger to your markup, you can call it in your aura component's controller:
({
logSomeStuff: function (component, event, helper) {
const logger = component.find("logger");
logger.error("Hello, world!").addTag("some important tag");
logger.warn("Hello, world!");
logger.info("Hello, world!");
logger.debug("Hello, world!");
logger.fine("Hello, world!");
logger.finer("Hello, world!");
logger.finest("Hello, world!");
logger.saveLog();
},
});
- Assigning Permission Sets to Users
- Configuring Global Feature Flags
- Configuring Profile & User-Specific Settings
- Configuring Data Mask Rules
Manual Instrumentation
- Logging in Apex
- Logging in Flow & Process Builder
- Logging in Lightning Web Components & Aura Components
- Logging in OmniStudio
- Logging in OpenTelemetry (OTEL) REST API
ISVs & Package Dependencies
- Overview
- Optionally Use Nebula Logger (When Available) with
Callable
Interface - Require Nebula Logger with Strongly-Coupled Package Dependency
Troubleshooting
Pub/Sub with Platform Events
Persisted Data with Custom Objects
- Logger Console app
- Assigning & Managing Logs
- Using 'View Related Log Entries' Component on Record Pages
- Deleting Old Logs
Official Plugins