> For the complete documentation index, see [llms.txt](https://knowledgebase.qommentary.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://knowledgebase.qommentary.com/qommentary-writeback/advanced/audit-trails/enable-audit-trails-for-database.md).

# Database audit trailing

To enable audit logs for databases you need to create a new table for auditing and then enable audit logs option at the extension level.

### Create a new table for auditing

Before using audit logs, you need to create a new table in your database to store the logs. The structure of this table must be the same as the writeback table with 3 additional columns: ActionAt, ActionBy and ActionType.

| Column         | Type     | Description                                                      |
| -------------- | -------- | ---------------------------------------------------------------- |
| **ActionAt**   | datetime | Date and time when the action was performed                      |
| **ActionBy**   | string   | Which user performed the action (UserDirectory\UserId)           |
| **ActionType** | string   | What action was performed  ( C = create, U = update, D= delete ) |

### Enable audit logs in the extension

1\. Open the properties panel and click on the Data Connections section

<div align="left"><img src="https://1677646431-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M43RhGzV8Plu0tfknia%2F-MYtPUNJxkHISlsp7dsq%2F-MYtQCKCjuOeqcLi0mqS%2Fimage.png?alt=media&amp;token=9016ae1e-7fa0-4722-841c-ba3724a554cd" alt=""></div>

{% hint style="warning" %}
You need to set up a connection before enabling logs
{% endhint %}

2\. Go to the *Enable audit logs* option

<div align="left"><img src="https://1677646431-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M43RhGzV8Plu0tfknia%2F-MYwUHc9NScafO6HSLsU%2F-MYwVVG21hLIrFSefVR4%2Fimage.png?alt=media&amp;token=93b6f212-dfdd-453b-9e48-bfc3dcda16b2" alt=""></div>

3\. Click on the switch control to enable audit logs

<div align="left"><img src="https://1677646431-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M43RhGzV8Plu0tfknia%2F-MYwUHc9NScafO6HSLsU%2F-MYwVhTZjFnawaRDIk-t%2Fimage.png?alt=media&amp;token=98e672a9-ed5b-4db3-8179-48419c3d5e8c" alt=""></div>

4\. Enter the name of the log table (e.g. Customers\_log)

<div align="left"><img src="https://1677646431-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M43RhGzV8Plu0tfknia%2F-MZCdiveeLUJ_c4tXvCw%2F-MZCn_t3gz8cCmPp0pWF%2Fimage.png?alt=media&amp;token=82d01e1d-ef37-4a35-875f-2fe5f3010f3f" alt=""></div>
