Create Log for reports

Hellow everyone in the community. I’ve been having problem about logs. honestly i don’t know how to use them and even if i read the documentation on logs i barely even understand. also video tutorials is hard to follow and understand. I’m new to using logs so i don’t really know how to use them very well.

I want to get logs for the user data in database. add, edit, delete… the details i need are those information inputted on the table. making them display in the log. ex: test added, test renamed to welcome, welcome has been deleted.

I’m very sorry for the trouble. I’m a student and still learning about this things. I would be so glad if someone can point me to the right direction on how to start. Thank you so much for responding to my post.

There are plugins out there which do these kinds of stuff but first I would recommend you try to understand the basics of logging which I tried to show in https://www.youtube.com/watch?v=iyvZRTBu41k

The next thing you need to learn is the fact, that you can hook into the ORM via event methods as you can see here: Table Objects - 4.x

You can do this on a per table basis or you can hook into the global event manager and listen for all e.g. Model.afterSave and Model.afterDelete events.

Inside e.g. the Model.afterSave you have access to the $entity->isNew() method which tells you if the entity already existed or was just created (aka update vs insert)

And the combination of all of these things will let you implement a log file which tells you what you need

1 Like

thank you for commenting to my post. i appreciate your help kind sir. I will do your recommendations and learn more about it in the documentation you provided. Thank you so much.

hellow good sir. It looks like im having problem with the datasource in the plugin you’ve suggested.i’ve done the necessary steps in installing the plugin, the audit stash plugin and elastic search on the composer, put the elastic configuration on the app.php. im running my server based on bin\cake server on cakephp and i just putted it on 127.0.0.1 since that ip if im not mistaken is for loop back. I’ve done mostly up to using audit stash in the plugin document. but now it shows that error. have you sir perhaps encountered this problem and solved it? i would really be glad to hear for your guidance on this matter. Thank you so much

elastic search is a separate, java programm you need to run and setup to work with this plugin.

its not really straight forward to setup though, thats why I recommended the ORM events and logging.


you can use the TablePersister of that plugin but I have never used it

thank you for the information sir. I’m very glad that you commented on my post. the information you provided has became useful to me. thank you.

Used this in CakePHP 2 but it wasn’t updated

I’ve created a basic behaviour in CakePHP 4 that does the same job although its a bit tailored to my app

1 Like

thank you for providing me the link. i’ll be sure to check it out. thank you.