> For the complete documentation index, see [llms.txt](https://gia-duong-duc-minh.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gia-duong-duc-minh.gitbook.io/notes/computer/microservices/audit-logging.md).

# Audit logging

## Context

You have applied the \[\[Microservice architecture]] pattern.

## Problem

How to understand the behavior of users and the application and troubleshoot problems?

## Forces

It is useful to know what actions a user has recently performed: customer support, compliance, security, etc.

## Solution

Record user activity in a database.

## Examples

This pattern is widely used.

## Resulting Context

This pattern has the following benefits:

* Provides a record of user actions
* This pattern has the following drawbacks: The auditing code is intertwined with the business logic, which makes the business logic more complicated

## Related patterns

\[\[Event Sourcing]] is a reliable way to implement auditing
