How to log Hold time when incoming call is patched to an Agent's IP Phone?

Hi in my setup incoming calls come to the Asterisk Server over ISDN. These calls are then patched to the Available Agent’s IP Phones registered on Asterisk as peers in sip.conf.
I am using Dial function in the dialplan to patch the calls.
Now I want to log the Hold Time for these calls i.e. the time for which the Agent kept the call on hold (by pressing the hold button on the IP Phone). When Agent Presses Hold button on IP Phone the Caller starts listening to MOH but I could not find out a way to log the duration for which the call was kept on hold.

Maybe you need to swicht to Queues instead plain dial… hmm but that not resolve the hardware onhold, maybe you need to start listening AMI events and check the event when MOH is started from phone’s agent.

Yes that is one option, in that case I will have to develop another Java client, I was trying to avoid that. Do you know about HOLD_INTERCEPT function? I just read about it, still trying to figure out how does it work. May be it can help.