With this Application a DB table APEX_CUSTOM_DEBUG_CONTROL is created. You can use such a table to remotely control when and where to activate DEBUG.
To set up the debugging go to
Page 99 and define the conditions.
The actual activation code is put in Shared Components -> Security -> PL/SQL Initialization section.
Again, this is just an idea on how to leverage APEX API's.