# View change history

The audit log tracks row, cell, and selection changes and undo/redo transitions. Use it to inspect change history that current values alone cannot reveal.

Canonical: https://grid.syidax.com/docs/features/audit-log/

<a id="understand"></a>

## How it works and when to use it

The log is an in-memory record with a retention limit. Services requiring long-term or legal audit records need separate server storage, access control, and retention policies.

In the code, grid is the Grid element prepared in the installation chapter. Check each example's data and settings, and implement the app functions and server endpoints for your project.

- [Installation and integration · Shared sample data](https://grid.syidax.com/docs/guides/getting-started.md)

<a id="example-1"></a>

## Example 1. Start recording

Enable logging and set retention before editing begins.

```javascript
grid.auditLog = true;
grid.auditLogMax = 1000;
```

Verify the result: Supported changes are recorded from then on. Earlier work is not reconstructed.

<a id="example-2"></a>

## Example 2. Read cell changes only

Use filters to narrow the records being inspected.

```javascript
const entries = await grid.getAuditLog({ kind: 'cell' });
console.log(entries);
```

Verify the result: Inspect each record's seq, time, source, and before/after values.

<a id="example-3"></a>

## Example 3. Share review records as JSON

Use JSON to preserve the structure.

```javascript
const json = await grid.getAuditLogAsJson(undefined, true);
console.log(json);
// From a user download button:
await grid.exportAuditLogAsJson('order-audit.json');
```

Verify the result: Choose a workflow for file review or app-server upload. Logs may contain sensitive previous values.

<a id="pitfalls"></a>

## Combining features and troubleshooting

clearAuditLog() clears the local record, not persistent server records. seq values are not reused.

Older entries are removed when the retention limit is exceeded. For complete long-term records, design event collection and server storage.

<a id="related-api"></a>

## APIs used by this feature

- [auditLog](https://grid.syidax.com/docs/options/auditLog.md) — Records row, cell, selection, and edit-history transitions in an audit log. Disabled by default and separate from long-term server retention.
- [auditLogMax](https://grid.syidax.com/docs/options/auditLogMax.md) — Maximum audit records retained in memory. Oldest records are removed when exceeded.
- [getAuditLog](https://grid.syidax.com/docs/methods/getAuditLog.md) — Reads audit records as an array, optionally filtered by type, sequence, or time. Returns an empty array when recording is disabled.
- [clearAuditLog](https://grid.syidax.com/docs/methods/clearAuditLog.md) — Clears retained audit records. Sequence numbers continue increasing and are not reused.
- [getAuditLogAsCsv](https://grid.syidax.com/docs/methods/getAuditLogAsCsv.md) — Converts audit records to CSV text for inspection or transfer without downloading a file.
- [getAuditLogAsJson](https://grid.syidax.com/docs/methods/getAuditLogAsJson.md) — Reads audit records as a structured JSON array string. Use pretty for readable indentation.
- [exportAuditLogAsCsv](https://grid.syidax.com/docs/methods/exportAuditLogAsCsv.md) — Downloads selected audit records as a CSV file.
- [exportAuditLogAsJson](https://grid.syidax.com/docs/methods/exportAuditLogAsJson.md) — Downloads selected audit records as a JSON file.
- [auditLogChanged](https://grid.syidax.com/docs/events/auditLogChanged.md) — Emitted when an audit record is added. Read entry to connect your app's retention flow.

<a id="next"></a>

## Related reading

- [How rows, columns, and IDs relate](https://grid.syidax.com/docs/guides/concepts.md)
- [Connect results and events](https://grid.syidax.com/docs/guides/data-event-access.md)
- [Explore in Features](https://grid.syidax.com/grid/audit-log) — The guide describes which interactions are available to try.
