Newer Version Available

This content describes an older version of this product. View Latest

View Apex Debug Logs

Apex debug logs can record database operations, system processes, and errors that occur when executing a transaction or running unit tests in your scratch org. You can use the Salesforce CLI to view the debug logs.
  1. Open your scratch org by running force:org:open. If you have not set a default username, specify the scratch org’s username or alias with the -u parameter.
  2. Under the quick access menu (Lightning Experience) or your name (Salesforce Classic), click Developer Console. Opening the Developer Console starts a listener that is required by the force:apex:log commands.
  3. If necessary, run Apex tests to generate some debug logs.
    1sfdx force:apex:test:run
  4. Get a list of the debug logs.
    1sfdx force:apex:log:list
    2
    3APPLICATION  DURATION (MS)  ID                  LOCATION   SIZE (B)  LOG USER   OPERATION        REQUEST  START TIME                STATUS
    4───────────  ─────────────  ──────────────────  ─────────  ────────  ─────────  ───────────────  ───────  ────────────────────────  ───────
    5Unknown      1143           07L9A000000aBYGUA2  SystemLog  23900     User User  ApexTestHandler  Api      2017-09-05T22:58:57+0000  Success
  5. View a debug log by passing its ID to the force:apex:log:get command.
    1sfdx force:apex:log:get --logid 07L9A000000aBYGUA2
    2
    338.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
    415:58:57.3 (3717091)|USER_INFO|[EXTERNAL]|0059A000000TwPM|test-ktjauhgzinnp@your_company.net|Pacific Standard Time|GMT-07:00
    515:58:57.3 (3888677)|EXECUTION_STARTED
    615:58:57.3 (3924515)|CODE_UNIT_STARTED|[EXTERNAL]|01p9A000000FmMN|RejectDuplicateFavoriteTest.acceptNonDuplicate
    715:58:57.3 (5372873)|HEAP_ALLOCATE|[72]|Bytes:3
    8...