> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zentien.io/llms.txt
> Use this file to discover all available pages before exploring further.

# ErrorLogger Reference

> Full API reference for the ErrorLogger Apex class.

## Overview

`ErrorLogger` is a production-safe Apex utility class included in the Zentien package. It publishes errors as `ErrorEvent__e` Platform Events, which Zentien receives and stores in real time.

**Design principles:**

* Never throws — all methods are wrapped in try/catch. A failure to log will never break your calling code.
* No callout limits consumed — Platform Events use a separate publish limit (not the callout limit)
* Synchronous publish — errors appear in Zentien within seconds

## Methods

### `log(Exception e, String className, String methodName)`

Logs an exception with `ERROR` severity.

```apex theme={null}
ErrorLogger.log(e, 'MyClass', 'myMethod');
```

| Parameter    | Type        | Description                                 |
| ------------ | ----------- | ------------------------------------------- |
| `e`          | `Exception` | The caught exception                        |
| `className`  | `String`    | Name of the class where the error occurred  |
| `methodName` | `String`    | Name of the method where the error occurred |

***

### `log(Exception e, String className, String methodName, String severity)`

Logs an exception with a specified severity.

```apex theme={null}
ErrorLogger.log(e, 'MyClass', 'myMethod', 'CRITICAL');
```

| Parameter  | Type     | Description                                    |
| ---------- | -------- | ---------------------------------------------- |
| `severity` | `String` | One of: `INFO`, `WARNING`, `ERROR`, `CRITICAL` |

***

### `log(Exception e, String className, String methodName, String severity, String recordId)`

Logs an exception with severity and a related Salesforce record ID for additional context.

```apex theme={null}
ErrorLogger.log(e, 'MyClass', 'myMethod', 'ERROR', recordId);
```

| Parameter  | Type     | Description                                            |
| ---------- | -------- | ------------------------------------------------------ |
| `recordId` | `String` | ID of the related Salesforce record (optional context) |

## ErrorEvent\_\_e fields

The Platform Event published by `ErrorLogger` contains the following fields:

| Field               | Description                                  |
| ------------------- | -------------------------------------------- |
| `OrgId__c`          | The Salesforce Org ID                        |
| `EventType__c`      | Always `HANDLED` when logged via ErrorLogger |
| `AutomationType__c` | `Apex`                                       |
| `AutomationName__c` | The `className` parameter                    |
| `MethodName__c`     | The `methodName` parameter                   |
| `ErrorMessage__c`   | The exception message                        |
| `StackTrace__c`     | The exception stack trace                    |
| `RecordId__c`       | The `recordId` parameter (if provided)       |
| `UserId__c`         | The ID of the running user                   |
| `Severity__c`       | The severity level                           |
| `Environment__c`    | `production` or `sandbox`                    |
