Installation
Install the bundle and record your first entry.
Requirements
The bundle needs PHP 8.2 or later, Symfony 6.4, 7.x or 8.x, and symfony/framework-bundle. Each source and output needs its own package. See Sources and Outputs.
Install the bundle
The bundle is a private package on Private Packagist. Add the repository to your project:
$ composer config repositories.private-packagist composer https://repo.packagist.com/symfonycorp/Add your Private Packagist token to your global Composer configuration. Do not commit the token:
$ composer config --global --auth http-basic.repo.packagist.com token <TOKEN>Then install the bundle:
$ composer require symfonycorp/audit-logSymfony Flex registers the bundle. Without Flex, add it to config/bundles.php:
SymfonyCorp\AuditLog\AuditLogBundle::class => ['all' => true],Quick start
This example records each change of a Doctrine entity in a SQL table. It needs Doctrine and its migrations:
$ composer require symfony/orm-packSet DATABASE_URL in your .env file. Then enable a source, an output and the client IP:
symfonycorp_audit_log:
sources:
doctrine_orm: true
outputs:
dbal: true
context_providers:
request: true # the client IP, truncatedTo also record the logged-in user, see User, IP and request ID.
Add #[Auditable] to an entity:
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use SymfonyCorp\AuditLog\Attribute\Auditable;
#[ORM\Entity]
#[Auditable]
class Book
{
#[ORM\Id, ORM\GeneratedValue, ORM\Column]
public ?int $id = null;
#[ORM\Column]
public string $title = '';
}Create the tables. The migration creates the book table and the audit_log table:
$ bin/console doctrine:migrations:diff
$ bin/console doctrine:migrations:migrateWithout Doctrine migrations, run bin/console audit-log:setup to create the audit_log table.
Create a Book, for example in a controller:
$book = new Book();
$book->title = 'Dune';
$entityManager->persist($book);
$entityManager->flush();Read the entries:
$ bin/console audit-log:list
-------------------------------------- -------------- -------- ---------------------------------- ---------------------
Id Source Action Message Timestamp
-------------------------------------- -------------- -------- ---------------------------------- ---------------------
01a158b2-0deb-7198-9b1b-8a28b8380020 doctrine_orm INSERT Entity "App\Entity\Book" created 2026-10-20 09:43:46
-------------------------------------- -------------- -------- ---------------------------------- ---------------------No entry? - by default, a failed write is only logged. In development, set silent_failures: false to see the error. See Outputs.
Next steps
Enable more sources, choose your outputs, and see all the options in Configuration.