Add the listener only when trace enabled
Add Licence
Fixes #1824