Last updated
Last updated
AdminJS has some extra plugins which extend its basic functionality. One of them is logger.
The logger's purpose is to keep track of selected resources (i.e. tables) Every action performed on resource (new, edit, delete or bulkDelete) is registered in special object and persisted in database. Information about changes are monitored, so we can inspect and compare changes in every field of a table.
Installation is pretty simple. First we have to install @adminjs/logger
package
We can use any database and any ORM package as described in Adapters section.
Then we have to define Log
entity - the place we will track changes. Below you can find example
EntityLog
is related to entity User
because userId
holds reference to user who made changes
There is one thing worth to mention. We have to enable authorization before using this feature, because we will need user's ID for corresponding changes.
To get logger to work, add extra property to resource config. Below you can find simple example of such configuration.
To have Log resource appear in AdminJS panel, we have to define it first.
@adminjs/logger exports
createLoggerResource
function which does most of the work for you. You can customize it using it's configuration argument.
@adminjs/logger