Audit logs benefits and best practices
Tags: auditlogs, strapi
Published: 2023-03-09 12:10:19


Ensuring security, compliance, and transparency are crucial for any Strapi application. The best way to achieve this is by implementing [Audit Logs](https://docs.strapi.io/user-docs/latest/settings/audit-logs.html), a tracking and monitoring system that provides a record of actions performed within your Strapi application, including data changes, user activity, and system configurations.

In this article, we'll explain the reasons why Audit Logs are essential for your Strapi application  and share best practices to follow when implementing them.

## Understand the Importance of Audit Logs: What are they?

Audit Logs is a new feature released in [Strapi Enterprise v4.6](https://strapi.io/blog/announcing-strapi-v4.6). It is a system for **tracking and recording actions, changes, and events in your application**. You can track changes to data (content type, entry, media), user activity (login, logout), and system configuration (user roles and permissions). You can also see when the action was made, which user did it (name and ID), and the payload attached to the log. You can also filter the logs by action, date or user, and share a link to each particular log with your team members.
![audit logs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ge3sz77t3yog3zf5p3z.png)
[Self-hosted Enterprise Edition](https://strapi.io/pricing-self-hosted) customers can choose the duration of a period, during which the audit trails will be stored (90 days by default). The activity trails will be stored for 7 days in the [Strapi Cloud Team plan.](https://strapi.io/pricing-cloud)

There are many reasons you should implement audit logs, among them:

## Security

Get a detailed record of activities and changes made within your application. Detect and prevent security incidents and unauthorized access to sensitive information. 

If an unauthorized user tries to access sensitive information or make unauthorized changes, with this feature, you can record their actions and **quickly detect and respond to potential security incidents**. In the event of a security breach, you can track the actions of the attacker and determine what sensitive information may have been compromised, to investigate the incident and identify the source of the problem, enabling you to improve the security of your application and prevent future incidents.

Cyberattackers are evolving rapidly, which is reflected in the [64% of companies worldwide that experienced at least one cyber attack in 2022](https://techjury.net/blog/how-many-cyber-attacks-per-day/#gref), the importance of having robust security measures in place cannot be overstated.

## Events Tracing 
Human mistakes are unavoidable, so it’s important to have a way to track them when they take place and cause problems. Audit logs provide **a record of the activities that could have led to an issue**. This will ease the process of diagnosing and fixing issues when they arise. 

The logs within your Strapi application and other sources of information that show error messages, performance metrics, or application configuration settings can help you better understand an issue and identify the root cause of the problem. 

For instance, with this feature, you can trace errors when users encounter difficulties logging into your application due to an authentication configuration setting issue. Or, you can analyze the logs to identify any errors related to an authorized user’s inability to make changes to a collection-type, such as updating blog content. 

You can easily share a particular log with the team, and also filter logs by date, user or action to find the necessary log.
![audit logs filters.gif](https://d2zv2ciw0ln4h1.cloudfront.net/uploads/audit_logs_filters_1d5184d49d.gif)
This feature allows you to be cautious, proactively address problems as soon as they occur, and save time in solving problems when they arise.

## When are Companies Likely to Require This Feature? 
This is an important feature that would most likely help any business or organization that needs to meet compliance or keep a record of the activities performed within the application. Certain industries may find it especially useful to meet specific requirements: 

1.  [Financial Services](https://strapi.io/financial-services): Banks, insurance companies, and investment firms must comply with regulatory requirements such as PCI DSS regarding the security of sensitive financial information and payments. 

2. **Healthcare:** Hospitals and healthcare organizations have to comply with strict regulations related to patient data privacy and monitor access to sensitive data. More specifically, Audit logs are an important part of [HIPAA compliance](https://www.hhs.gov/hipaa/for-professionals/compliance-enforcement/audit/protocol/index.html) which in some cases requires Healthcare organizations to retain logs for up to 6 years.

3.  **Government:** Federal, state, and local governments should secure sensitive information and comply with regulations related to protecting government data. Audit logs is a specific requirement of [The Federal Risk and Authorization Management Program (FedRamp)](https://www.fedramp.gov/), 

4. **Technology:** Software and tech companies can monitor access to sensitive information or identify the root problem of any issue developing within the application. Audit logs are one of AICPA Trust Services Criteria to achieve SOC 2 compliance. 

5.  **Retail:** Retail businesses can monitor and track transactions and make sure to secure customers' sensitive information. 

6.  **Manufacturing:** Manufacturing companies can track changes made to production processes and ensure to secure sensitive information related to production or supply chains.

Regarding who should be responsible for managing the logs in your application, it is typically beneficial for IT administrators and security teams, compliance and regulatory organizations, or DevOps teams. By default, only Strapi Super Administrators have access to the audit logs feature.

## How Do Audit Logs Work?
[Audit logs](https://docs.strapi.io/user-docs/latest/settings/audit-logs.html#events-logged) is a feature now available to [Enterprise Edition](https://strapi.io/pricing-self-hosted) users and the [Strapi Cloud Team plan](https://strapi.io/pricing-cloud). You can find the logs of all activity within your environment available in [Settings](https://docs.strapi.io/user-docs/settings/audit-logs) in the [Admin Panel](https://docs.strapi.io/user-docs/latest/getting-started/introduction.html#accessing-the-admin-panel).

You can see a list of all the events with relevant information displayed on the right side of each event in the past seven days. The information displayed includes the date of the action, the user who performed it, and a details icon that opens a modal displaying additional information, such as the user’s IP address, the request body, etc.

You can filter the logs by date, action and user, as well as share a link to each particular log. 

Watch this video to see Audit logs in action and follow the [documentation](https://docs.strapi.io/user-docs/intro#accessing-the-admin-panel) for a step-by-step guide.

{% youtube 73a_434KbNM %}

You can try the Audit Logs feature out by signing up for a [free Strapi demo](https://strapi.io/pricing-self-hosted).