logging-framework

Publish Salesforce Apex logs via Platform Events with configurable retention.

2|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/bhanu91221/claude-sfdx-iq --skill logging-framework
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: logging-framework
Source: https://github.com/bhanu91221/claude-sfdx-iq/tree/main/skills/logging-framework
Command: npx skills add https://github.com/bhanu91221/claude-sfdx-iq --skill logging-framework

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This framework provides a robust, scalable approach to capturing and persisting application logs in Salesforce, avoiding DML usage in business logic by emitting events and storing structured data for audit and debugging.

Core Features & Use Cases

  • Platform Events driven logging: Decouples log creation from business transactions by publishing Log_Event__e.
  • Structured logs: Captures Level__c, Source__c, Message__c, Stack_Trace__c, Payload__c for rich context.
  • Retention & governance: Includes configurable retention policies and a scheduled cleanup to prevent data bloat.
  • Usage: Use LogService to log at various levels from Apex classes, with optional payloads to provide context.

Quick Start

Configure the LogService in your Salesforce org to emit logs with the desired level and retention policy.

Frequently Asked Questions about logging-framework

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement structured Apex logging without hitting governor limits?

Structured Apex logging without governor limits is achieved by decoupling log creation from business transactions using Platform Events. This framework publishes Log_Event__e asynchronously, capturing Level, Source, Message, Stack Trace, and Payload fields to avoid DML limits.

What is the best way to manage log retention and automated cleanup in Salesforce?

Log retention and automated cleanup in Salesforce are managed through configurable retention policies and a scheduled batch job. This framework includes scheduled cleanup automation to systematically delete old log records and prevent data storage bloat.

Can I capture custom payloads and stack traces in Salesforce Platform Events?

Capturing custom payloads and stack traces in Salesforce Platform Events is fully supported by this framework. It structures log data into specific fields including Payload__c and Stack_Trace__c to provide rich diagnostic context for debugging and auditing.

How do I set up asynchronous logging with configurable log levels in Apex?

Asynchronous logging with configurable log levels in Apex is set up by configuring the included LogService. You use LogService to emit logs at various severity levels from Apex classes, optionally attaching structured payloads for additional application context.

Does this Salesforce logging framework work for production applications?

This Salesforce logging framework is designed for production applications, providing a scalable approach to capturing diagnostic data and error details. It isolates logging logic via Platform Events to ensure robust auditing without impacting core business logic performance.

Why should I use Platform Events for Salesforce logging instead of direct DML?

Using Platform Events for Salesforce logging instead of direct DML prevents transaction overhead and governor limit exhaustion. This event-driven architecture decouples log persistence from business logic, enabling scalable diagnostic data capture across production apps.