function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Derrick Abbey 21Derrick Abbey 21 

No debug logs are being generated in my scratch org

Hi community,

I created a new scratch org for developing a new lightning web component.  I'm trying to debug it, but I can't see any debug logs in either the developer console or in settings.  I also tried pulling the from the CLI and it says that there aren't any logs.  I have set user and Apex class trace flags, but still no logs.  I know that the class is being called because it's returning data to the lightning web component.  Has anyone else encoutered this problem?
Khan AnasKhan Anas (Salesforce Developers) 
Hi Derrick,

Greetings to you!

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.
sfdx force:apex:test:run

4. Get a list of the debug logs.
sfdx force:apex:log:list

APPLICATION DURATION (MS) ID       LOCATION  SIZE (B) LOG USER  OPERATION       REQUEST START TIME   STATUS
─────────── ───────────── ───────  ───────── ──────── ───────── ─────────────── ─────── ───────────  ───────
Unknown     1143          07L9Axx  SystemLog 23900    User User ApexTestHandler Api     2017-09-05x  Success

5. View a debug log by passing its ID to the force:apex:log:get command.
sfdx force:apex:log:get --logid 07L9A000000aBYGUA2

38.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
15:58:57.3 (3717091)|USER_INFO|[EXTERNAL]|0059A000000TwPM|test-ktjauhgzinnp@example.com|Pacific Standard Time|GMT-07:00
15:58:57.3 (3888677)|EXECUTION_STARTED
15:58:57.3 (3924515)|CODE_UNIT_STARTED|[EXTERNAL]|01p9A000000FmMN|RejectDuplicateFavoriteTest.acceptNonDuplicate()
15:58:57.3 (5372873)|HEAP_ALLOCATE|[72]|Bytes:3
...

Please refer to the below links which might help you further.

https://developer.salesforce.com/blogs/2019/02/debug-your-lightning-web-components.html

https://www.mattgoldspink.co.uk/debugging-lwc-tests-vs-code/

https://developer.salesforce.com/docs/component-library/documentation/lwc/debug_intro

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas 
Derrick Abbey 21Derrick Abbey 21
Hi Khan, Thank you for the reply.  I had tried the developer console, enabling debug logs from the setup menu and checking for logs via the CLI.  I couldn't find logs with any of those methods.  

What I ended up doing is creating a separate user and logging in as that user.  Now, when I open the developer console as that user, I can see logs generated as I access the class.

Does that mean that there's something about the default admin user that's created using a scratch org where that user won't generate logs?