> For the complete documentation index, see [llms.txt](https://docs.pharos.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pharos.ai/configuration-guide/log-retention.md).

# Log Retention

Configure log retention rules to manage storage via removal or local archival.

As your org accumulates logs over time, Salesforce Data Storage can become a constraint. Log retention rules let you automatically remove or archive old log records on a daily schedule — giving you control over what stays and what goes without manual cleanup.

The rule system follows the same filter-then-action framework as [notifications](https://docs.pharos.ai/configuration-guide/notifications.md) and [ticketing](https://docs.pharos.ai/configuration-guide/ticketing/rules.md): set an age threshold, add optional filters, and choose an archival action.

{% hint style="info" %}
For retention strategies and best practices, see [Data Retention](https://docs.pharos.ai/platform-overview/pharos-platform-architecture/logs/log-storage/data-retention.md).
{% endhint %}

***

## Accessing Log Retention

1. Open the **Pharos** app → **Pharos Admin**
2. Select **Log Retention** from the left-hand menu

The page lists all configured retention rules and provides the global **Enable Log Retention** toggle:

![Log Retention Rules — landing page with Enable Log Retention toggle (disabled)](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-e031c5209a7f9090ee3fefde1289f32adab8ebe0%2Flog-retention-disabled.png?alt=media)

Turn the toggle on to activate rule evaluation. When enabled and rules exist, the page shows rule counts and the rules list:

![Log Retention Rules — enabled with 1 active rule ("Blank Functional Area" with Removal action)](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-36ab3b22eabbc501a9826e3ef8dfe08227e0449f%2Flog-retention-enabled.png?alt=media)

***

## Creating a Retention Rule

Click **Add New Rule** to open the rule form. Each rule has four sections: Rule Details, Age, Filter Criteria, and Actions.

![Log Retention Rule form — "Delete Old Logs" rule with 1 year age, empty Filter Criteria and Actions sections](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-993a32a0079c947467b078ca83fb6c2b393cfdba%2Flog-retention-rule-form.png?alt=media)

### 1. Rule Details

Provide a **Rule Name** and **Description** that document the rule's purpose. Example: *"Remove all logs older than 6 months"* or *"Remove ee prod errors with blank functional area."*

### 2. Age

Set the minimum age a log record must reach before the rule applies. The **Interval** dropdown provides common presets (1h, 8h, 1 week, 1 month, 6 months, 1 year, 2 years). You can also enter a custom value in days:

![Age setting — custom value of 700 days](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-273e40a89b08ec1b86aca618cd98dbf9c0726d75%2Flog-retention-age-custom.png?alt=media)

Logs older than the specified interval become eligible for the rule's action.

### 3. Filter Criteria (Optional)

Narrow which logs the rule affects. Without filters, the rule applies to **all** logs that meet the age threshold. Filters can be based on any field on the Log record — Category, Functional Area, Organization Name, etc.

**Simple filter** — exclude Apex logs from removal:

![Filter Criteria — Category Not equal Apex](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-a02bbed96e1de456f8f27f9013953089f4382686%2Flog-retention-filter-criteria.png?alt=media)

**Advanced filter with Filter Logic** — combine multiple criteria with custom boolean expressions (e.g., `1 AND 2`):

![Filter Criteria — two filters with Filter Logic expression "1 AND 2"](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-c2669c49975a858fb7137ef4fe8d84fba2ca4e44%2Flog-retention-filter-logic.png?alt=media)

By default, all criteria must be satisfied (AND). Use the **Filter logic** option to override with custom expressions like `(1 AND 2) OR 3`.

### 4. Actions

Click **Add New** to create an archival action, then choose from the **Send new archival action to** dropdown:

![New Archival Action dropdown — Removal and Local Archival options](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-ee9f4a2a3a0abccadee81986b2da4c72910712c9%2Flog-retention-action-dropdown.png?alt=media)

| Action             | What Happens                            | When to Use                                                     |
| ------------------ | --------------------------------------- | --------------------------------------------------------------- |
| **Removal**        | Permanently delete log records          | Free Data Storage; no need to keep logs                         |
| **Local Archival** | Copy logs to Big Objects before removal | Preserve for compliance or audit while freeing standard storage |

Each action requires a **Description** (e.g., "Delete", "Save to Big Object"):

![New Archival Action — Removal selected with Description "Delete"](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-b1d638cc90917f411c1792644639821edc092f70%2Flog-retention-action-removal.png?alt=media)

You can attach multiple actions of different types to a single rule. Multiple archival actions of the same type are not supported. When both archival and removal are configured, archival runs first:

![Actions section — Removal (Delete) and Local Archival (Save to Big Object) configured on one rule](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-fc1d957d051e16db3ad35f1fde913b5ceba4f2f3%2Flog-retention-actions-list.png?alt=media)

***

## Example: Targeted Cleanup Rule

This rule removes logs from a specific org with a blank functional area after just 1 hour — a short interval for high-volume, low-value records:

![Log Retention Rule — "Blank Functional Area" with 1h age interval, targeted filter criteria](https://4264222071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fdl9tmJ56lvwg5XY63QYr%2Fuploads%2Fgit-blob-ff9da777326145c317c8b74075e1966121adf5d5%2Flog-retention-rule-targeted.png?alt=media)

***

## Editing Active Rules

{% hint style="warning" %}
Once a retention rule has been activated and has executed at least once, certain fields become read-only — specifically the **Age** interval and **Filter Criteria**. This is because Pharos is actively processing logs against the rule and cannot update these parameters on the fly.

To change the age or filters of a running rule:

1. **Deactivate** the existing rule
2. **Create a new rule** with the updated criteria

You can still rename the rule, update its description, and modify actions on an active rule.
{% endhint %}

***

## How It Runs

Retention rules execute **automatically on a daily schedule**. Key behaviors:

* All active rules are evaluated against eligible log records
* Only **log records** are affected — Issues are not directly deleted by retention rules
* If all logs under an issue are removed, the **issue is automatically deleted** as well
* File attachments (e.g., Bulk API error files) attached to deleted log records are also cleaned up, freeing File Storage
* Deleted logs free **Data Storage** immediately
* There is no on-demand run — rules fire on the daily schedule. If you need an immediate cleanup, contact Pharos support to request a manual execution

***

## Recommendations

* **Keep as much data as storage allows.** The more historical data you retain, the more insights you can derive from trends, occurrence patterns, and year-over-year comparisons.
* **Only add rules when storage is constrained** or compliance requires it. Monitor your storage for 60–90 days before deciding on retention periods.
* **Start with longer intervals** (1 year) and shorten only if needed. You can always delete data later, but you cannot recover deleted logs.
* **Use filters for targeted cleanup.** Rather than a blanket "delete everything after 6 months," create category-specific rules: keep Apex logs longer (more debugging value), remove high-volume Flow or Bulk API logs sooner.
* **Consider archival before removal.** Local Archival to Big Objects preserves data for compliance while freeing standard Data Storage.

***

## Troubleshooting

| Issue                                  | Cause                                                                 | Resolution                                                     |
| -------------------------------------- | --------------------------------------------------------------------- | -------------------------------------------------------------- |
| Rules not running                      | Global toggle off or rule inactive                                    | Enable **Enable Log Retention** toggle; check rule Active flag |
| No logs removed                        | Age threshold not met or filters too strict                           | Verify logs exist that meet age and filter criteria            |
| Cannot edit age or filters             | Rule has already executed                                             | Deactivate the rule and create a new one with updated criteria |
| Storage not decreasing                 | Not enough eligible logs yet                                          | Wait for next daily run; check storage breakdown               |
| Archived logs didn't free Data Storage | Local Archival copies to Big Objects, which use a separate allocation | Pair Local Archival with a Removal action on the same rule     |

***

## Related

* [Data Retention](https://docs.pharos.ai/platform-overview/pharos-platform-architecture/logs/log-storage/data-retention.md) — Retention strategies and best practices
* [Connected Orgs](https://docs.pharos.ai/configuration-guide/connected-orgs.md) — Offload logs to a monitoring org as an alternative to deletion
* [Notifications](https://docs.pharos.ai/configuration-guide/notifications.md) — Same rule-based pattern for alerting
* [Ticketing Rules](https://docs.pharos.ai/configuration-guide/ticketing/rules.md) — Same rule-based pattern for ticket creation
