How to Use APEX_DEBUG for Troubleshooting in Oracle APEX

Oracle APEX offers robust debugging tools that help devs identify issues, optimize performance, and ensure smooth user experiences. The apex_debug package is central to this, providing detailed insight into your app’s behavior at runtime. Here’s a practical guide to using apex_debug and related features for debugging and tuning your APEX apps.
How to enable APEX_DEBUG?
There are several ways to enable debug mode in APEX:
Developer toolbar: Click the "debug" button in the developer toolbar while running your application.
URL parameter: Append &p_debug=YES or &p_debug=LEVEL (where level is 1–9) to your application URL for different verbosity levels.
Application property: Set the application’s debug property to "yes" for persistent debug logging.
APEX_DEBUG API: Use apex_debug.enable in PL/SQL to programmatically enable debugging for a session.
Logging Dynamic Values and Parameters
apex_debug.info('My Debug message, showing order_id: %s', p_order_id);
apex_debug.warn('unexpected status: %s', p_status);
apex_debug.error('Warning, my debug error: %s', sqlerrm);
| Procedure | Purpose & Level | When to Use |
apex_debug.error | Level 1 (Critical error) | For logging critical errors or failures that require immediate attention or may halt processing. |
apex_debug.warn | Level 2 (Warning) | For logging important, non-critical issues that should be reviewed but do not stop processing. |
apex_debug.info | Level 4 (Informational, default level) | For routine information, such as variable values, process steps, or general progress messages. |
apex_debug.trace | Level 6 (Trace) | For detailed, low-level tracing of code execution, such as inside loops or complex logic blocks. |
View the debug messages
To view the debug messages, click on "View Debug" in the dev toolbar, or go to Utilities / Debug Messages, or also running the following query:
select *
from apex_debug_messages
Logging in Loops and Bulk Operations
Be careful when logging too many messages, for example, inside a loop. Be aware of APEX flood control, which limits the number of debug messages per page view (the default is 50,000).
You can check this limit with the query below (run as sys).
select *
from APEX_INSTANCE_PARAMETERS
where name = 'DEBUG_MESSAGE_PAGE_VIEW_LIMIT';
Debugging Outside APEX Applications
You can use apex_debug in standalone PL/SQL scripts or jobs:
apex_session.create_session(p_app_id=>101, p_page_id=>1, p_username=>'RODRIGO');
apex_debug.enable(apex_debug.c_log_level_info);
apex_debug.info('My debug message from sql developer');
apex_session.detach;


The APEX debug feature is very powerful and useful. To help you troubleshoot issues, enable debug mode and use the browser’s developer tools to inspect AJAX calls and dynamic actions. The debug log will display the sequence and timing of events, helping you identify problems with client-side interactivity.






