When we start debugging our session values in APEX, we usually use the DEBUG option in our developertoolbar. But did you know there are different debugging levels?
If we take a closer look to our URL once we started the debug we see the following; https:/servername.com/apex/f?p=APP_ID:APP_PAGE_ID:SESSION::YES:::
In this case YES mains the debugger is on. The default debugging level is level 4. This we can see in our “View Debug” option on the developer toolbar; click on your identifier and you will see something simulair;
What does this mean?
Once we started the debugger it defaults to level 4, this means we get to see al the APEX debug messages for level 4 and down to level 1. In this case I got 135 entries to check in the debugger.
Levels
To understand the levels we can debug in, we check the documentation for APEX_DEBUG. This has the following contstants;
subtype t_log_level is pls_integer;
c_log_level_error constant t_log_level := 1; -- critical error
c_log_level_warn constant t_log_level := 2; -- less critical error
c_log_level_info constant t_log_level := 4; -- default level if debugging is enabled (for example, used by apex_application.debug)
c_log_level_app_enter constant t_log_level := 5; -- application: messages when procedures/functions are entered
c_log_level_app_trace constant t_log_level := 6; -- application: other messages within procedures/functions
c_log_level_engine_enter constant t_log_level := 8; -- Application Express engine: messages when procedures/functions are entered
c_log_level_engine_trace constant t_log_level := 9; -- Application Express engine: other messages within procedures/functions
/*The funny thing is; what happend to level 3 and 7?*/
If we look at the info above, when we debug at level 4 we get to see all Critical Errors, less critical errors / warnings and information logging.
Use another level?
It can happen ofcourse we need more logging, or we just cant seem to find the message we are looking for. It which case, we should up the level of debugging. The easiest way to up your debugging level is to change your URL;
https:/servername.com/apex/f?p=APP_ID:APP_PAGE_ID:SESSION::LEVEL9:::
The following entries can be made in the URL; (Make sure its uppercase!)
- LEVEL1*
- LEVEL2*
- LEVEL3*
- LEVEL4
- LEVEL5
- LEVEL6
- LEVEL7
- LEVEL8
- LEVEL9
- YES
- NO
* Sidenote; When using level 1 till 3, and there is no level 1 till 3 logging, there will be no result
I usually use level 9, this because you get to see all messages. If we compare Level 4 entries with level 9 entries we see we get a lot more information! If we check the details we see that we got a lot more information for the higher levels;
Custom Messages
If you want more debugging info in your debug about your function / procedure, you can also use APEX_DEBUG.message. Default you will always enter them to level 4.
apex_debug.message('Your log here for variable: ' ||l_variable);
To test if we can use all levels I used the apex_debug_message and logged something for all levels, even though levels 3 and 7 are not in the contstant, you can use them!
Don’t forget, with apex_debug.error you can always force a debug message to show up, even if you didn’t turn on debugging 😉
LikeLiked by 1 person
Good tip!! Or use APEX_DEBUG.ENABLE to force full debug 🙂
LikeLike