28
votes
Accepted
Get Currently Executing Class/Method Name?
My first thought (which does work) is to throw and catch a DmlException (or any Exception type you wish), and use its stack trace string as a starting point.
public class StackTrace
{
public ...
16
votes
Console.log truncates my debug `...}`
[UPDATE 2022]: This is no longer true (for some time already), see
other answers.
This is a feature (although in this case you may not view it as such, understandably) of the built in toString on ...
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
Console.log truncates my debug `...}`
The JSON.serialize(...) trick no longer works, if one needs un-truncated messages following wrapper class is what I use, I just paste it as helper method at bottom of the apex class in those ...
14
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.
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:
...
10
votes
Console.log truncates my debug `...}`
If you are debugging large objects or lists, enclosing your debug contents with JSON.serializePretty(), eg:
system.debug(JSON.serializePretty(hugeAccountList));
will insert line breaks, which allow ...
9
votes
Accepted
Expense of using System.debug
I have seen too many debugs double the processing time and at times cause the apex time limit exceeded. There is a cost to everything we do.
In addition writing
system.debug('Here');
is less ...
9
votes
Accepted
MAXIMUM DEBUG LOG SIZE REACHED
Generally speaking, you can control the logging level using the TraceFlags.
TraceFlags have overriding authority over all other tracing methods. See Summer '15 Release notes - Receive Debug Logs ...
9
votes
Salesforce Email Service Debugging
The likely answer comes from the comment by @MarcDBehr
Email Services can have several Email Addresses. Each Email Address has a context user (i.e. running user)
You need to enable debug logging for ...
8
votes
Best practice to monitor Apex function execution time/performance?
Have a look at the Event Monitoring API. You can use it to pull an event log file down for certain event types.
From docs for EventLogFile:
The event monitoring feature allows you to gather ...
7
votes
Accepted
Exceptions and DML
The transaction will only be rolled back automatically if the thrown exception isn't caught.
Your example showed a call stack like:
Class A calls Class B
Class B calls Class C
Class C attempts a ...
6
votes
Console.log truncates my debug `...}`
Wrapping your list variable with JSON.serialize(your_list_here) should solve your issue.
For example:
System.debug(JSON.serialize(list_var));
6
votes
Accepted
What is the 'INTERNAL' debug level?
I have been informed by technical support that R&D has investigated the issue, and that this value will be removed from the UI at some point. As such, we shouldn't use this value for debugging.
Community wiki
6
votes
Accepted
How to change log levels for apex tests
In the console, go to Debug > Change Log Levels. You'll see the following dialog:
If you want a specific setting for your tests, click the Add button, and name it something like Test_Debug. Usually I ...
5
votes
Accepted
How to disable the debug log for other classes except for my class?
In the dev console just set everything to error
5
votes
Where can I read the debug output of test classes
In VS Code, go to the terminal window and enter this command:
sfdx apex:tail:log --color | grep USER_DEBUG
Then run your tests. The debug messages will show up in the Terminal window. Note that ...
5
votes
MAXIMUM DEBUG LOG SIZE REACHED
Debug statements shouldn't generally be used. Instead, in the console, go to the line of code where you want a snapshot, cluck the line number to create a checkpoint, then run the test. Afterwards, ...
5
votes
Accepted
Debug Log of deployment test execution
Yes, if you have dev console open while you are deploying. With Change Sets, you can avoid log truncation by running specified tests.
5
votes
Accepted
What do the colors in Developer Console's Save Order tab represent?
According to the Winter 14 Release Notes
The Save Order tab displays a color-coded timeline of DML actions. For
each DML action taken, save order elements are shown as boxcars in the
timeline.
...
5
votes
Accepted
Custom Logging and Future Methods
The future method simply hasn't executed yet by the time the caller completes.
Maybe what you could do is pass an identifier from the calling class to the future method. The future method passes this ...
5
votes
Custom Logging, @Future, Transaction Control
Nope, you can't do that with a future method, or with a Queueable, or Batch Apex, because all of those asynchronous invocations are enqueued for execution after the transaction's over - and that ...
4
votes
What do the colors in Developer Console's Save Order tab represent?
Official documentation for the Execution Overview Save Order.
The following colors are used to differentiate between elements:
Color : Type
Red : Before trigger
Orange : After trigger
...
4
votes
Accepted
Streaming logs in API 37 and up
Confirmation from twitter that they are making changes around supporting platform events in the future. Twitter Exchange:
Me
Why would the #Salesforce Developer Console still be using v36 of cometD ...
4
votes
Access to debug logs in managed package
If you can, it's much better to use the License Management App application to access the debug logs from a managed package installed in a client org.
You'll find limited usage for a custom object ...
4
votes
Send Logging Marketing Cloud Email Sends
The Send Logging feature needs to be enabled in your account for this template to be available. So you need to reach out to your account executive or log a new case in salesforce help & training ...
4
votes
Logging frameworks that use Platform Events - what is the full list?
The other idea I would throw in there is to make the logging implementation a plug-in.
In my own spin on this, I have a unified Logger class where each call to log includes an identifier of which ...
3
votes
Accepted
Logging batches?
If you want to maintain something between batches, you'll need to implement database.stateful. Otherwise, you'll only be able to carry something from one scheduled batch start to the next scheduled ...
3
votes
Accepted
Apex Job - Writing to a log
They end up in up to two different places: the Developer Console and Debug Logs. If you enable logging for the user that scheduled the job (Setup > Monitoring > Debug Logs), it will appear here. ...
3
votes
Issues displaying logs in Developer Console? Possibly Summer 15 related
I have also been experiencing this. Here are the steps that I have taken to 'fix it' quotes are because the fix seems to expire... sigh!
In the dev console debug ==> change log levels set the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
logging × 149apex × 45
debugging × 33
marketing-cloud × 14
developer-console × 13
debug × 11
exception × 8
trigger × 7
unit-test × 6
email × 6
api × 6
visualforce × 5
managed-package × 4
deployment × 4
error × 4
future × 4
debug-logs × 4
batch × 3
dataextensions × 3
scheduled-apex × 3
schedulebatch × 3
performance × 3
bug × 3
try-catch × 3
lightning-aura-components × 2