One minor inconvenience when using the APEX debug features is the amount of noise which fills up the debugger when I try to find my debug messages.
For example, I have the following Before Header Process. Line 2 calls a DB procedure.
When I review the debugger I see dozens of APEX framework messages which I’m not currently interested in. I then have to zoom up and down trying to locate my custom debug messages.
Sometimes I insert some text e.g. Matt and then use the browser search features to find the debug messages at that point.
Is there a better way?
I’ve evaluated several approaches to this and I’m going to blog about just 2 methods. Each method works by getting the debug IR to highlight the row containing the custom debug message. Each method has its own pros and cons – so if you would like to use one of these methods then please weigh-up the factors and decide for yourself.
The main problem faced here is getting the debug IR to recognise which message is custom and which is framework
The simplest way is to message at log level 3. This is achieved something like the below
Then you just need to add this highlight rule to debugger
Click Apply, and suddenly your custom debugger messages leap off the page.
You can also save the report as a public report.
I mentioned there were cons:
First decide on a character which would never appear as a first character in a debug string. For this example, I’m going to pick the ~ symbol. Then you would prefix your debugger statements with this symbol.
In debugger; you’ll have to change a few extra things
Step 1: Create a Compute Column as per below
Step 2: Deselect the Message Column and ensure the **Message column is below Execution as per below
Step 3: Add a Highlight rule as per below
You can even extend the compute columns a little further: for example, whenever I debug in server side code I’m going to use the ó prefix which I obtained by holding ALT GR + O
In this case I need to change my compute column to
CASE WHEN INSTR(B,1,1) IN (‘~’,’ó’) THEN SUBSTR(B,2) ELSE B END
The final result being
On to the Cons
Overall, using these techniques can enable developers to quickly locate debug message by row-highlighting. Each method has its pros and cons. I hope that in newer released of APEX we’ll get that additional column indicating which is a custom message and which is a framework message – that way it would be much clearer and easier to apply IR row highlighting.
If you prefer option A, then I would advise using your own procedure which was a wrapper to apex_debug.message. If debugging at log level 3 stops working in a future version, then it’s just a case of converting your wrapper procedure to the prefix method.
Author: Matt Mulvaney
Job Title: Senior Oracle APEX Development Consultant
Bio: Matt is an experienced APEX solution designer having designed numerous complex systems using a broad range of Oracle Technologies. Building on his previous experience of Oracle Forms & PL/SQL, he is entirely focused on providing functionally rich APEX solutions. Matt promotes APEX as a software platform and openly shares best practises, techniques & approaches. Matt has a passion for excellence and enjoys producing high quality software solutions which provide a real business benefit.