I'm using developer console log to see all my debug logs but it cuts off my log after 1920 characters

How do I fix that? and even I have tried download the log and open in a notepad++ but still I see the cut off

CurrencyIsoCode=USD}), ...} <<<<<


This is a feature (although in this case you may not view it as such, understandably) of the built in toString on apex collection types. The idea being that since the debug log has a maximum size debugging a single large collection would truncate other potentially valuable log lines.

System.debug however does no such truncation, so any string you pass to it should be displayed accurately in your logs.

As BobTheBuilder mentioned you can serialize your collection to JSON, as this creates a full-length string which you can then pass to System.debug and get the full un-abbreviated value. You could also iterate over your collection to build a large string yourself and debug that. Basically as long as you don't rely on the toString implementation of system types you're free to get log whatever you like.

  • 2
    This is no longer true. Even using JSON.serialize(), single-line strings are limited to 500 characters. For Objects or Collections, the linebreaks inserted by JSON.serializePretty() will let you exceed 500. Alternately (or in addition), you can use regex to inject newline characters directly into your string before debugging. – Aubry Jan 4 '20 at 20:42

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 situations I need un-trunctated logs:

public void mDebugUntruncated(String sMsg) {
    for (Integer i = 0; i < sMsg.length(); i=i+300) {
        Integer iEffectiveEnd = (i+300 > (sMsg.length()) ? sMsg.length()-1 : i+300);

Then for example you would call it as you would call it with:

this.mDebugUntruncated('=== QV_QuickLinkListLoader.getContent(...):`JSON.serialize(sJSONRequest)=' + JSON.serialize(sJSONRequest) +'`');

un-trunctated salesforce debug message

  • 1
    This seems to truncate the last character for the last debug line. – Jacob Raccuia Nov 6 '19 at 19:40
  • 1
    Yeah, remove the -1's from line 3 – Seph Cordovano Jan 1 '20 at 0:18
  • Updated, thanks @SephCordovano – Daniel Sokolowski Jan 10 '20 at 17:08

Wrapping your list variable with JSON.serialize(your_list_here) should solve your issue.

For example:


  • 2
    This does not appear to be working for me anymore, anyone else have truncation even with the JSON.serialize trick? – Daniel Sokolowski Apr 15 '19 at 13:42
  • @DanielSokolowski did you find anything on it? – apple123 Apr 23 '19 at 18:15
  • @apple123 I ended up creating a small wrapper class for whenever I need to workaround this limit. – – Daniel Sokolowski Apr 23 '19 at 18:51
  • @DanielSokolowski that sounds interesting, would you be kind enough to share a few details on it? or a little snippet of the code? – apple123 Apr 23 '19 at 22:18
  • @apple123, yes of course, see my answer below (or above). – Daniel Sokolowski Apr 24 '19 at 13:11

If you are debugging large objects or lists, enclosing your debug contents with JSON.serializePretty(), eg:


will insert line breaks, which allow your debug to exceed the normal character limit. For long solid strings, however, you will need to inject linebreaks manually, which I do using this:

public static void multiLineDebug(Object debugContents){
    String debugText = JSON.serialize(debugContents);
    Pattern lengthLimit = Pattern.compile('(.{299})');
    debugText = lengthLimit.matcher(debugText).replaceAll('$1\n');

If you prefer one-line solutions, you can do this:

system.debug(Pattern.compile('(.{299})').matcher(JSON.serialize( /* PUT YOUR DEBUG CONTENTS HERE */ )).replaceAll('$1\n'));

Though I suspect there are some issues with optimization there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.