---
agentTools:
  projectIndex: https://merchello.readme.io/llms.txt
---

# AuditLogService

Describes the AuditLogService

The AuditLogService is intended to be used to log Merchello related informational records that would not otherwise be normally recorded in an application's generic logging system.

**Examples are**

Payment authorized, Shipment Shipped and Order created records.

[block:api-header]
{
  "type": "basic",
  "title": "Instantiating",
  "sidebar": true
}
[/block]

[block:code]
{
  "codes": [
    {
      "code": "var auditLogService = MerchelloContext.Current.Services.AuditLogService;",
      "language": "csharp"
    }
  ],
  "sidebar": true
}
[/block]

[block:textarea]
{
  "text": "The AuditLogService is exposed through the `MerchelloContext`",
  "sidebar": true
}
[/block]

[block:api-header]
{
  "type": "basic",
  "title": "Class"
}
[/block]

[block:code]
{
  "codes": [
    {
      "code": "public class AuditLogService : PageCachedServiceBase<IAuditLog>, \n\tIAuditLogService, IPageCachedService<IAuditLog>, IService",
      "language": "csharp"
    }
  ]
}
[/block]

[block:api-header]
{
  "type": "basic",
  "title": "Constructors"
}
[/block]

[block:parameters]
{
  "data": {
    "h-0": "Name",
    "h-1": "Description",
    "0-0": "AuditLogService()",
    "1-0": "AuditLogService(ILogger)",
    "2-0": "AuditLogService(IDatabaseUnitOfWorkProvider, RepositoryFactory, ILogger)",
    "0-1": "Initializes a new instance of the AuditLogService class.",
    "1-1": "Initializes a new instance of the AuditLogService class.",
    "2-1": "Initializes a new instance of the AuditLogService class."
  },
  "cols": 2,
  "rows": 3
}
[/block]

[block:api-header]
{
  "type": "basic",
  "title": "Public Methods"
}
[/block]

[block:parameters]
{
  "data": {
    "h-0": "Name",
    "h-1": "Description",
    "0-0": "CreateAuditLogWithKey(String, ExtendedDataCollection, Boolean, Boolean)",
    "0-1": "Creates an audit record and saves it to the database",
    "1-0": "CreateAuditLogWithKey(Nullable(Guid), EntityType, String, Boolean, Boolean)",
    "2-0": "CreateAuditLogWithKey(Nullable(Guid), Nullable(Guid), String, Boolean, Boolean)",
    "3-0": "CreateAuditLogWithKey(Nullable(Guid), EntityType, String, ExtendedDataCollection, Boolean, Boolean)",
    "4-0": "CreateAuditLogWithKey(Nullable(Guid), Nullable(Guid), String, ExtendedDataCollection, Boolean, Boolean)",
    "1-1": "Creates an audit record and saves it to the database",
    "2-1": "Creates an audit record and saves it to the database",
    "3-1": "Creates an audit record and saves it to the database",
    "4-1": "Creates an audit record and saves it to the database",
    "5-0": "Delete(IAuditLog, Boolean)",
    "6-0": "Delete(IEnumerable(IAuditLog), Boolean)",
    "7-0": "DeleteErrorAuditLogs",
    "5-1": "Deletes a IAuditLog",
    "6-1": "Deletes a collection of IAuditLog",
    "7-1": "Deletes all error logs",
    "8-0": "GetAuditLogsByEntityKey",
    "9-0": "GetAuditLogsByEntityTfKey",
    "10-0": "GetByKey",
    "11-0": "GetErrorAuditLogs",
    "12-0": "GetPage",
    "12-1": "Gets a Page of AuditLogs",
    "11-1": "Gets a collection of IAuditLog where IsError == true",
    "10-1": "Gets an IAuditLog by it's key",
    "9-1": "Gets a collection of IAuditLog for an entity type",
    "8-1": "Gets a collection of IAuditLog for a particular entity"
  },
  "cols": 2,
  "rows": 13
}
[/block]

[block:api-header]
{
  "type": "basic",
  "title": "Events"
}
[/block]

[block:parameters]
{
  "data": {
    "h-0": "Name",
    "h-1": "Description",
    "0-0": "Creating",
    "1-0": "Created",
    "2-0": "Deleting",
    "3-0": "Deleted",
    "4-0": "Saving",
    "5-0": "Saved",
    "0-1": "Occurs before create",
    "1-1": "Occurs after create",
    "2-1": "Occurs before delete",
    "3-1": "Occurs after delete",
    "4-1": "Occurs before saving",
    "5-1": "Occurs after saved"
  },
  "cols": 2,
  "rows": 6
}
[/block]

[block:api-header]
{
  "type": "basic",
  "title": "Interface on GitHub"
}
[/block]

[block:embed]
{
  "html": false,
  "url": "https://github.com/Merchello/Merchello/blob/master/src/Merchello.Core/Services/Interfaces/IAuditLogService.cs",
  "title": "Merchello/Merchello",
  "favicon": "https://assets-cdn.github.com/favicon.ico",
  "image": "https://avatars2.githubusercontent.com/u/6453072?v=3&s=400",
  "iframe": false
}
[/block]

<https://github.com/Merchello/Merchello/blob/master/src/Merchello.Core/Services/Interfaces/IAuditLogService.cs>