Logging operations in lightadmin

148 views Asked by At

I have a Java web application which use Spring and Hibernate and I plan to use lightadmin to provide an administration interface.

However, I found very little information about the logging part of lightadmin : if I have such an adminsitration interface, I would like that any operation made to our data (such as create, update or delete) is logged in our custom logger (it's not on a file but on a table on the database, this choice has already been made and implemented long time ago).

My need is to have a log entry containing some information (might be just the id) about the modified rows. Is there a global way to configure it?

Or can I add a logging annotation somewhere in each class which extends AdministrationConfiguration? If yes, where?

1

There are 1 answers

1
khanou On BEST ANSWER

You can use the class AbstractRepositoryEventListener like it's show on the LightAdmin documentation here

Add you logger insertion by overiding onAfterSave, onAfterCreate and onAfterDelete into your own RepositoryEventListener.

After you just need to register your listener like this

public class YourAdministration extends AdministrationConfiguration<YourObject> {

    public EntityMetadataConfigurationUnit configuration(EntityMetadataConfigurationUnitBuilder configurationBuilder) {
        return configurationBuilder
                .repositoryEventListener(YourRepositoryEventListener.class)
                .build();
    }

}