0

I have the following trigger:

trigger HelloWorldTrigger on Account (before insert) {
    System.debug('Hello World!');
}

I checked that the trigger code is saved. Now I run the following anonymous apex:

Account a = new Account(Name='Test Trigger');
insert a;

After the anonymous apex is run I am presented with the log view (I am using Developer console here). So, in the log view I select Debug Only and hope to see the text Hello World!. I expect it to happen because my anonymous apex inserted a new record of type Account and hence the trigger should have run and output the Hello World!. But I do not see the text. What am I doing wrong here?

I will attach a few screenshots of the process described above:

enter image description here

enter image description here

enter image description here

Here is a similar question. It is telling:

In your debug level check in Apex code debug is set

So, I go to Debug -> Change Log Levels.. and I get confused: I do not know what exactly should I change here. enter image description here

Another thing to do inferring from the question provided is to check the log size. I did not know how to do that, but the question tells:

its on debug log page. You will find the debug size in bytes. You need to convert them.

I am looking at the log page an do not see any debug size information there:

enter image description here

Help me, please. I want to see this Hello World! text in my log.

Here is the Trailhead module which I was learning before encountering the issue.

Here are the screenshots of me trying to tweak the debug log using the Setup:

enter image description here enter image description here enter image description here enter image description here

After this I go to developer console and try to do the same things and getting the same result (no output is generated).

2 Answers 2

2

It works for me. The only things to keep in mind here are:

  1. 'Apex Code' is set to at 'Debug' in Debug Level.
  2. The log size is not greater than 2MB.
  3. The user you want the logs for has a valid entry in debug logs: Start Date and Expiration Date.

enter image description here

Still no dice? Try setting all log categories to 'None' in your debug level and set just Apex Code to 'Error' and try:

System.debug(logginglevel.ERROR, '---------------> Hello World!');
1

There is one more solution that you have to create debug log in setup. Please see below for the steps to create debuglog.

Goto -> Setup -> Search by "debug logs" and click on "debug logs" link.

Click on "New" button and select "Traced Entity Name" as logged in User Name and select any one of debug level which is shows in lookup(Make sure apex code should be debug).

Execute your account insert code via execute anonymous window and refresh the debug log page and you can find newly generated debug log and open it, find your debug name.

Please let me know if you have any queries on this.

2
  • I suppose I am not getting your guide clearly, because it does not work for me. So, I will provide screenshots of completing your guide in the question, please, check them if you will have an opportunity. Thank you.
    – iloveseven
    Jul 27, 2018 at 10:28
  • Hi, After executing developer console code, you have to refresh Debug log page and you can find newly generated debug log list Jul 27, 2018 at 10:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .