@ -9,6 +9,8 @@ This module implements the Audit Logging system of an application;
* See all changes of entities and filter entity change logs.
* View details of an entity change.
* View all changes of an entity.
* Export audit logs and entity changes to Excel.
* Receive email notifications for completed or failed exports.
* This module also defines reusable "Average Execution Duration Per Day" and "Error Rate" widgets.
* Periodic clean up of audit logs.
@ -56,6 +58,10 @@ You can view details of an audit log by clicking the magnifier icon on each audi
* **Actions:** This tab shows list of actions (controller actions and application service method calls with their parameters) executed during a web request.
* **Changes:** This tab shows changed entities during the web request.
##### Export to Excel
You can export audit logs to Excel by clicking the "Export to Excel" button in the toolbar. If the result set is small (less than a configurable threshold), the file will be generated and downloaded immediately. For larger result sets, the export will be processed as a background job and you'll receive an email with a download link once the export is completed.
#### Entity Changes
Entity changes tab is used to list, view and filter entity change logs.
@ -80,6 +86,10 @@ You can view details of all changes of an entity by clicking the "Full Change Hi
You can export entity changes to Excel by clicking the "Export to Excel" button in the toolbar. Similar to audit logs export, for large datasets the export will be processed as a background job and you'll receive an email notification once completed.
#### Audit Log Settings
The *Audit Log* settings tab is used to configure audit log settings. You can enable or disable the clean up service system wide. This way, you can shut down the clean up service for all tenants and host. If the system wide clean up service is enabled, you can configure the global *Expired Item Deletion Period* for all tenants and host.
The *Period* doesn't mean the *Expired Item Deletion Period*. It's the period of the worker to run clean up service system wide. The default value is 1 day.
### AuditLogExcelFileOptions
`AuditLogExcelFileOptions` can be configured in the UI layer, within the `ConfigureServices` method of your [module](../framework/architecture/modularity/basics.md). Example:
```csharp
Configure<AuditLogExcelFileOptions>(options =>
{
options.FileStoragePath = "wwwroot/audit-logs"; // Default path where Excel files are stored
options.FileRetentionHours = 24; // How long to keep files before cleanup (default: 24 hours)
options.DownloadBaseUrl = "https://yourdomain.com"; // Base URL for download links in emails
options.ExcelFileCleanupOptions.Period = (int)TimeSpan.FromHours(24).TotalMilliseconds; // Interval of the cleanup worker (default: 24 hours)
});
```
> Note: The `FileRetentionHours` value determines when files become eligible for deletion, but actual deletion depends on when the cleanup worker runs. If the worker hasn't run after the retention period expires, files will remain accessible. Therefore, `FileRetentionHours` represents the minimum intended retention time, but the actual retention time might be longer depending on the worker's execution schedule.
These settings control where Excel export files are stored, how long they are kept before automatic cleanup, and what base URL is used in email download links.
## Internals
### Domain layer
@ -156,6 +184,15 @@ Following custom repositories are defined for this module:
* `AuditLogsAppService` (implements `IAuditLogsAppService`): Implements the use cases of the audit logs management UI.
#### Email Templates
The module provides email templates for notifications:
* `AuditLogExportCompleted`: Sent when an audit log export is successfully completed, including a download link.
* `AuditLogExportFailed`: Sent when an audit log export fails, including error details.
* `EntityChangeExportCompleted`: Sent when an entity change export is successfully completed, including a download link.
* `EntityChangeExportFailed`: Sent when an entity change export fails, including error details.