21
votes
How to Delete All Debug Apex logs in Apex?
You cannot delete the debug logs natively in Apex code. But you can use Rest DELETE endpoint to delete debug logs.
I have created a utility code to delete debug logs that way, you can refer it.
The ...
19
votes
Accepted
How are we supposed to use debug logs for a specific Apex class only
Realistically, all you can do is set the user trace flags to a debug level with all levels set to "none", then set the class's log to a debug level that you want. Yes, you'll still be generating a ton ...
19
votes
Accepted
System.debug(JSON.Serialize(o)) Not longer shows full string
Unfortunately, since Spring'19 in order to improve performance, Salesforce changed a way how long strings are shown in the Developers Console.
Now strings are now truncated at 512 characters in the ...
16
votes
Maximum log level exceeded in Developer Console
I believe I saw the fix to this on SFSE, but can't seem to find it now. When having this issue, run this query in your Query Editor:
SELECT Id FROM ApexLog
Then simply delete all rows.
16
votes
Accepted
Developer Console suddenly truncating System.Debug output
Sounds like they added something to the Dev console to truncate long lines in spring 19 (On March 20, 2019 according to the Release Note changes).
Developer Console: String Values in Debug Logs Are ...
14
votes
Accepted
Maximum log level exceeded in Developer Console
The short term solution is to keep playing whack-a-mole~ApexLog as Adrian has suggested.
Longer term, the problem comes back to the Summer'18 update Store Larger Debug Logs with Changed Log Limits:
...
13
votes
System.debug(JSON.Serialize(o)) Not longer shows full string
I always recommend using Checkpoints; this gives you an easy way to inspect the entire heap (memory). You can learn more about this in the trailhead Inspect Objects at Checkpoints. Simply open the ...
12
votes
Accepted
What is the purpose of Apex Class Trace flags?
Class and trigger trace flags override other logging levels, including logging levels set by user trace flags, but they don’t cause logging to occur.
As you quoted, simply setting a class trace flag ...
10
votes
Accepted
Debug Log Traced Entity Type Apex Class
You need to also set a TraceFlag on the user you want to trace. A TraceFlag set on a class only overrides the TraceFlag settings for the user; you use them together to get detailed analysis on a ...
10
votes
Accepted
is there a way to check a debug statement belongs to which class
Open the log in dev console and select Debug Only. Then select the columns File and Method
In the above image, File corresponds to the Id of class which can be opened directly from url with /<--Id-...
9
votes
Accepted
How to obtain trigger log from Email2Case?
The running user for Email to Case is found in Setup | Customize | Cases | Support Settings under the field Automated Case User if you are using On-Demand E2C
The user listed in the Case History ...
8
votes
Accepted
Writing too much to debug log increases heap and cpu time
Yes, this is expected, and perfectly normal. Each time you call System.debug, the object you pass in must serialized, even if the system eventually doesn't end up putting anything in to the log, and ...
7
votes
How to Query ApexLog raw body?
You don't name a use case, or whether there is a particular place you are integrating this from. But if it was just a matter of, "I need to get a log out and check for some string value in it," these ...
7
votes
How are we supposed to use debug logs for a specific Apex class only
The short answer is, you can't. The class specific debug levels only control how verbose the logging for those classes are.
When the user executes an action, all the classes within the same context ...
7
votes
How to see anonymous code debug logs in visual studio code?
You can see the logs by
Opening the Command Palette and enter sfdx get in the search box
Then choose SFDX: Get Apex Debug Logs... After a few seconds, you are prompted to select a debug log to ...
7
votes
Accepted
Mass delete Debug logs using Salesforce DX
The following worked for me
sfdx force:data:soql:query -q "SELECT Id FROM ApexLog" -r "csv" | out-file -encoding oem out.csv
sfdx force:data:bulk:delete -s ApexLog -f out.csv
With ...
7
votes
Accepted
Is there a way to create Trace Flags for certain user using SFDX?
Yes, you can create a Trace Flag via command line.
The command for creating a new Trace Flag:
sfdx force:data:record:create --sobjecttype TraceFlag -v "StartDate=$NOW ExpirationDate=$EXP ...
6
votes
Accepted
Omit debug logging for specific Apex class
It is not possible to get debug logs with arbitrary logging levels to omit VARIABLE_ASSIGNMENT and other basic profiling information unless you move your code to a Managed Package.
6
votes
is there a way to check a debug statement belongs to which class
The line numbers do appear in the debug logs, e.g.
08:02:34:164 USER_DEBUG [375]|DEBUG|LINE ITEM COUNTER B:1
That "[375]" in the log is the line number that this particular system.debug(); ...
6
votes
Accepted
How to see anonymous code debug logs in visual studio code?
I would make sure you have an active User Trace Flag. I have noticed that in vscode sometimes you need to have your user trace flag set even when running anonymous apex.
6
votes
Mass delete Debug logs using Salesforce DX
The following worked fine for me in MAC
sfdx force:data:soql:query -q "SELECT Id FROM ApexLog" --resultformat csv > out.csv
sfdx force:data:bulk:delete -s ApexLog -f out.csv
I have not ...
6
votes
Accepted
Who runs Email-to-Case
You can check the Support Setting and look for "Automated Case user" that user is used for Email-to-Case
5
votes
Accepted
Enabling Debug Logs
You will need to automate the creation of the TraceFlag record for the user in question. This could be done either via Apex calling the Tooling API, or via an external process.
TraceFlag records are ...
5
votes
Accepted
How do I set the log levels for force:apex:log:tail?
You need to set the debug level on the DEVELOPER_LOG trace flag for your user. It is written in the documentation:
-d | --debuglevel DEBUGLEVEL
Optional
Debug level to set on the DEVELOPER_LOG trace ...
5
votes
How to analyze Apex CPU consumption
I don't know if you're open to something commercial, but Illuminated Cloud's Log Analyzer has specialized views for profiling various resources including CPU time, heap, SOQL queries and DML, etc.
...
5
votes
Accepted
Reading Debug Logs to Determine What's Using CPU TIme
CPU time is, at the moment, a global resource. If package A uses 200ms, then calls package B that uses 12,000ms, then A uses another 100ms, it may trip the CPU limit, even though it was really package ...
4
votes
Accepted
unable to get the debug log of a site guest user
You can do this by adding a browser cookie. See the release notes here
Salesforce does not debug the guest site user by default because they can generate a lot of debug logs.
4
votes
How to Delete All Debug Apex logs in Apex?
As far as I can tell, the documentation is mistaken in showing that ApexLog can be deleted from Apex DML.
The object is deletable from the Tooling API, however. You can tackle this in two ways:
You ...
4
votes
Is it possible to know WHY SOQL retrieves EMPTY?
If the apex class is running in with sharing context then the record level access will kick in the SOQL queries, where it will check if record is shared to the running user or not.
Record Access gets ...
4
votes
Accepted
Proxy on all Objects and Arrays logged in LWC - Salesforce
my solution that appeared to fix the problem:
You must also have “Use Lightning Web Security for Lightning web components” disabled in your org for this method
Setup > Session Settings > ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
debug-logs × 136apex × 51
debugging × 32
debug × 19
developer-console × 17
salesforcedx × 11
trigger × 8
apex-debugger × 7
managed-package × 6
vs-code × 6
soql × 5
batch × 5
visual-workflow × 5
cpulimit × 5
visualforce × 4
lightning × 4
lightning-web-components × 4
salesforcedx-cli × 4
logging × 4
apex-replay-debugger × 4
unit-test × 3
community × 3
rest-api × 3
visualforce-component × 3
error × 3