backend, Dec 1, 2026—4 min read

Loggastic 2: Symfony activity logs in the storage you choose

Keeping track of who changed what is a common need on most bigger projects. Support wants to know what happened to an order, developers want to debug it, and sooner or later somebody asks for an audit trail.

In 2023 we open sourced Loggastic, our Symfony bundle for exactly that, and introduced it on this blog. It had one big requirement back then: the logs lived in Elasticsearch, so you had to run a cluster only for your activity logs. Today we are happy to share Loggastic 2. Your logs can now live in the database you already have, in Elasticsearch, or in your own storage, and the setup is still a few lines.

What is Loggastic?

Loggastic is a bundle built on top of the Symfony framework. It tracks the changes made on your objects and their relations, and it lets you choose which fields you want to track. Every create, edit and delete becomes an activity log, with the time, the user and the values before and after the change.

How simple is the setup?

The setup has three steps:

  1. Add the Loggable attribute to your entity.
  2. Put a serialization group on every field you want to track.
  3. Run one command that creates the tables or the indexes.
The setup of Loggastic: the Product entity has the Loggable attribute and a serialization group on its name and on its variants, the related ProductVariant entity has the group on its price, and fields without the group are not logged. One console command creates the storage.

The bundle comes with a built-in Doctrine listener that detects every create, edit and delete on your loggable entities, so you don’t write any logging code. The listener sends a message to Symfony Messenger, and a handler compares the object with its last known state and saves the log. By default this happens right away, and you can make it asynchronous with a few lines of Messenger configuration.

The quick start in the README has the three steps with the code.

You choose the fields, in relations too

Serialization groups give you full control over what gets logged:

  • A field with the group is tracked. A field without it never reaches the log, so a password, a token or a big text field stays out.
  • The same group works across relations. Put it on the relation and on the fields of the related object that matter to you, and you track exactly those.

Take a product with variants. You put the group on the variants and on the price of a variant. When somebody changes one price, the history of the product shows it:

{
    "previousValues": {
        "variants": {
            "8": {
                "price": 20
            }
        }
    },
    "currentValues": {
        "variants": {
            "8": {
                "price": 25
            }
        }
    }
}

8 is the ID of the variant. You get one readable history per object, also when the change happened on a related object, and the log holds only what changed. The README shows how a related object sends its changes to its parent.

Which data is stored in an activity log?

An activity log contains the action, the date and time, the user who made the change, the request URL and the before and after values. We store before and after values only for the fields that changed, which saves space and makes the log easy to read. This is the log of a renamed blog post:

{
    "action": "Edited",
    "loggedAt": "2026-12-01T12:52:25+00:00",
    "objectId": "3",
    "objectClass": "App\\Entity\\BlogPost",
    "dataChanges": {
        "previousValues": {
            "title": "My first post"
        },
        "currentValues": {
            "title": "My updated post"
        }
    },
    "requestUrl": "PATCH example.com/api/blog_posts/3",
    "user": {
        "username": "admin"
    },
    "context": null
}

Logging also goes beyond create, edit and delete. You can save a log for actions that don’t change data, a sent newsletter or a downloaded PDF for example, and it shows up in the same history.

Where are the logs stored?

This is the biggest change in Loggastic 2. One config option selects the storage:

  • Your database: two tables in the database your app already uses. It works with PostgreSQL, MySQL, SQLite and any other database that Doctrine DBAL supports, and you need no extra infrastructure.
  • Elasticsearch: still the default, and still a great fit for fast log browsing on high-traffic data. Loggastic 2 supports Elasticsearch 8 and 9.
  • Your own storage: the bundle only talks to three small interfaces. You implement them, point them to your classes, and Loggastic uses your storage.
The storages of Loggastic 2: Doctrine keeps the logs in two tables of your database, Elasticsearch keeps two indexes per entity and is the default, and the in-memory storage keeps the logs in the PHP process for tests. For any other storage, you write three classes for three interfaces.

For your test suite there is also an in-memory storage, so your tests run the whole logging flow with no tables and no Elasticsearch. It is small, which makes it a good template for your own storage too. The README describes the built-in storages and the steps for a custom storage.

What else is new?

  • Request context: since 2.2 a log can also keep the IP address, the user agent, the original user during impersonation, and your own values such as a tenant. Everything is opt-in. See Saving request context.
  • A Symfony Flex recipe: run composer require locastic/loggastic, answer y when Flex asks about the recipe, and you get a registered bundle and a config file with the database storage selected.
  • API Platform examples: the README shows how to expose the logs as an API endpoint with any storage. The examples are tested with API Platform 4.1 to 5.0.
  • Symfony 8 is supported.

Upgrading from 1.x

If you use Loggastic 1.x, you can stay on Elasticsearch, because it is still the default storage. Version 2.0 is a major release, and the change you will most likely notice is that it needs Elasticsearch 8 or 9. Please read UPGRADE-2.0.md before you update.

Let us know what you think

Head over to the Loggastic GitHub repository and try it out. The new API Platform examples exist because somebody opened an issue, so if something is missing for your project, open one or send a pull request. We would love to hear how Loggastic 2 works for you! 🙂


You liked this? Give Paula a .

0