Spring 16 Class-level trace flags overriding general trace flags when more restrictive
Last updated 2016-12-08 ·Reference W-2978433 ·Reported By 4 users
Summary
Trace flags get overridden if an apex class, whose debug level of Apex Code is set to some level which filters out the METHOD_EXIT event like DEBUG, calls a method of some apex class whose Apex Code is also set to a level that filters out the METHOD_EXIT event.
For example, if an apex class whose debug level of Apex Code is set to DEBUG calls a method of an apex class whose Apex Code is NONE, the debug level of Apex Code remains in NONE even after the method call. And any messages via the System.debug() calls get never logged.
Repro
1. Create an apex class which calls the system.debug() method in its method.
public class DebugLevelNONE {
public static void aMethod() {
System.debug('This message is not logged');
}
}
2. Create a new trace flag for the apex class created at the previous step, and set the debug level of Apex Code to NONE.
3. Create an apex class which calls the method of the apex class which was created at the step 1, and leave its trace levels Default, whose Apex Code level should be DEBUG.
public class DebugLevelDEBUG {
public static void doLevelTest() {
System.debug('Before the DebugLevelNONE.aMethod() call.');
DebugLevelNONE.aMethod();
System.debug('After the DebugLevelNONE.aMethod() call. This messages should be logged.');
}
}
4. Execute the following code via workbench/dev console.
DebugLevelDEBUG.doLevelTest();
5. The debug logs will show something like this:
00:29:01.9 (9579610)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
00:29:01.9 (11601466)|SYSTEM_MODE_ENTER|false
00:29:01.9 (13398462)|USER_DEBUG|[3]|DEBUG|Before the DebugLevelNONE.aMethod() call.
00:29:01.9 (14322297)|PUSH_TRACE_FLAGS|[4]|01pxx00000002a0|DebugLevelNONE|APEX_CODE,NONE;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
00:29:01.9 (14823771)|SYSTEM_MODE_EXIT|false
As you can see, the message "Before the DebugLevelNONE.aMethod() call." is logged, but the message "After the DebugLevelNONE.aMethod() call. This messages should be logged." is not.
This behavior has changed in Spring 16 and it is considered a regression
Workaround
None
Reported By (4)
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.