-1

I am working on admin panel of a project and i just want to log every activity same as in activity logs in facebook.

Bushra Saifi
  • 103
  • 1
  • 12
  • Yes you can do that. But you have to be a bit more precise what you want to do and what you want to log – Simon Martinelli Nov 09 '19 at 08:27
  • I want to log each and every activity of admin e.g, every update ,delete and insert in tables – Bushra Saifi Nov 09 '19 at 08:30
  • That's no problem. And what exactly to you want to know? – Simon Martinelli Nov 09 '19 at 08:34
  • I think you can do something like this, as in this link: https://stackoverflow.com/questions/30118683/how-to-log-sql-statements-in-spring-boot – cipriancus Nov 09 '19 at 08:34
  • Initially I have created a table which is having fields like actionTakenOn and takenBy, but got stuck when it comes to the update api where i need to maintain the previous values, new value and field name also so that i can show that logs in user readable format. @SimonMartinelli – Bushra Saifi Nov 09 '19 at 08:40
  • yes i can go in this way..but my concern is I want to show that logs to admin who is not technical , i just need them in user readable format and more specific @cipriancus – Bushra Saifi Nov 09 '19 at 08:45
  • I already added a comment to you other question. Here you will find what you are looking for https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#events – Simon Martinelli Nov 09 '19 at 09:17

1 Answers1

1

Then I think what you can do is, you can create an advice on the methods that do the database work. Inside the advises check for user current permission ( e.g.: admin, I think it's in a principle and spring security gives this to you ) then you can create a message and write it in the table with the fields actionTakenOn and takenBy from where you can query and show the user.

I think this is quite a big feature, not sure if you will be able to get a complete answer with code examples.

cipriancus
  • 21
  • 1
  • 5