Collecting items when you destroy something?

Hello how would i destroy something and collect whatever prize was in that gameObject?
So for example i destroy a tree with my axe and when i destroy it theres a floating item on the ground which is a log and then you collect it. How would i do something like that?

You can use the OnDestroy() function to be called from a script attached to the gameObject representing your tree (or any other along the tree hierarchy).

Within the function you should be handling the collection of logs or what ever objects you wish to collect.

The same script could have access to this collection before the destruction takes place.