MongoDB
Store the entries in a MongoDB collection through a Doctrine ODM document manager.
Overview
| Package | Reads | Purge | Setup |
|---|---|---|---|
doctrine/mongodb-odm-bundle | Yes | Yes | Yes |
The commands, the EasyAdmin viewer and ReaderInterface can read this output. audit-log:purge and audit-log:setup work with it. See Outputs.
Enable the output
symfonycorp_audit_log:
outputs:
mongodb:
document_manager: ~ # null = the default one
collection: audit_logdocument_manager: the name of the document manager. Default:null, the default one. This option is not linked tosources.doctrine_odm.collection: the collection of the entries. Default:audit_log.auto_setup: create the collection and its indexes on the first write. Default:false. See Create the collection.
Create the collection
The output does not create its collection by default. Without it, a write can fail, and the bundle only logs the failure. Run the setup command when you deploy:
$ bin/console audit-log:setup --output=mongodbThe command creates the indexes on id (unique), occurredAt, (source, occurredAt), (action, occurredAt) and each key of indexed_context.
In development and in tests, you can set auto_setup: true to create the collection on the first write. Do not use it in production.
Indexed context - when you change indexed_context, run audit-log:setup before you deploy. It creates the missing indexes. See the context filter.