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
David MatusowDavid Matusow 

error when using system.debug

suddenly, I'm always getting a format error when using system.debug().  No matter what I put in the call, apex indicates that there is a format error.  Even something with nothing else there fails.
public class debugtest {

    System.debug('testing');
}
it says "expecting right parenthesis, found "testing"

Any ideas???
RatanRatan
you can't add statement direct in class. you need to debug in constructer or method
 
public class debugtest {
   public debugtest (){
      System.debug('testing');
  }
}

execute in developer console 
debugtest obj = new debugtest();

And chcek debug logs

OR
 
public class debugtest {
  
 public debugtest (){

}
   public void checklogs(){
      System.debug('testing');
  }
}

execute in developer console 
 
debugtest obj = new debugtest();

obj.checklogs();

And chcek debug logs

 
Amit Chaudhary 8Amit Chaudhary 8
Add Statment and debug inside method. like below
public class debugtest {
   public debugtest (){
      System.debug('testing');
  }
}
If you just want to test you code then you can use the developer console. Please check below post.
https://help.salesforce.com/apex/HTViewHelpDoc?id=code_dev_console_execute_anonymous.htm&language=en

User-added image

1) Click Debug | Open Execute Anonymous Window to open the Enter Apex Code window.
2) Enter the code you want to run in the Enter Apex Code window or click to open the code editor in a new browser window. To automatically open the resulting debug log when execution is complete, select Open Log.
3) Execute the code:
4) If you selected Open Log, the log will automatically open in the Log Inspector. After the code executes, the debug log will be listed on the Logs tab. Double-click the log to open it in the Log Inspector.
5) To execute the same code again without making changes, click Debug | Execute Last. If you want to modify the code, clickDebug | Open Execute Anonymous Window, to open the Enter Apex Code window with the previous entry.

Let us know if this will help you.