Developer Console Basics (2024)

Learning Objectives

After completing this unit, you’ll be able to:

  • View debug logs in the Log Inspector or a text editor.
  • Set various log levels for your debug logs.
  • Manage and switch perspectives using the Log Inspector.

View Debug Logs

As a good commander, you review the system logs to check that everything is in working order. Logs are one of the best places to identify problems with a system or program. Using the Developer Console, you can look at various debug logs to understand how your code works and to identify any performance issues.

View Logs in the Text Editor

Viewing a debug log is simple. To generate a log, let’s execute the EmailMissionSpecialist Apex class that you created earlier.

You can view your log in two ways.

  • Before execution, enable Open Log in the Enter Apex Code window. The log opens after your code has been executed.
  • After execution, double-click the log that appears in the Logs tab.

Let’s try the first method.

  1. Select Debug | Open Execute Anonymous Window.
  2. The Enter Apex Code window displays the last code that you entered for execution. If it’s different from the following code, delete it and paste the following code. Be sure to replace Enter your email addresswith your email address.
    EmailMissionSpecialist em = new EmailMissionSpecialist();em.sendMail('Enter your email address', 'Flight Path Change', 'Mission Control 123: Your flight path has been changed to avoid collision ' + 'with asteroid 2014 QO441.');
  3. Select the Open Log option.
  4. Click Execute.

The execution log that you see probably seems like a confusing jumble of numbers and words, so let’s talk about how you can read and understand log data.

Developer Console Basics (1)

Read Your Log Data

Let’s run the EmailMissionSpecialist class again, but this time let’s introduce an error. Then, let’s find the resulting log in the Logs tab.

  1. Select Debug | Open Execute Anonymous Window. Provide an invalid email address, such as testingemail.
    EmailMissionSpecialist em = new EmailMissionSpecialist();em.sendMail('testingemail', 'Flight Path Change', 'Mission Control 123: Your flight path has been changed to avoid collision ' + 'with asteroid 2014 QO441.');
  2. Deselect the Open Log option.
  3. Click Execute.After you run the code, you see a dialog box that includes the error.Developer Console Basics (2)
  4. Click OK, and then double-click the new log in the Logs tab. If you’re not sure which log is newest, click the heading for the Time column to sort the logs by the time when they were generated.Developer Console Basics (3)

You can read a debug log by identifying what each column represents.

  • Timestamp—The time when the event occurred. The timestamp is always in the user’s time zone and in HH:mm:ss:SSS format.
  • Event—The event that triggered the debug log entry. For instance, in the execution log that you generated, the FATAL_ERROR event is logged when the email address is determined to be invalid.
  • Details—Details about the line of code and the method name where the code was executed.

Developer Console Basics (4)

You can change what you see in the Execution Log by selecting This Frame (a), Executable (b), or Debug Only (c). Selecting these options shows you only certain types of events. For instance, Debug Only shows USER_DEBUG events. You can also filter different parts of the log using Filter (d). Enter a method name, or any other text you are specifically looking for, and the log filters your results.

You can also view the debug log as a raw log, which shows you more information. Select File | Open Raw Log. The timestamp in a raw log shows the time elapsed in nanoseconds (in parentheses) since the start of the event.

Developer Console Basics (5)

This combination of the timestamp, event, and details provides valuable insights into how your code works and the errors that occur.

While all this information is great, what if you want to quickly look for certain values in the debug log? After all, you have many other responsibilities as commander. An excellent way to do so is to use the System.debug() method in Apex.

The great thing about System.debug() is that you can add it anywhere in your code to track values, helping you debug your own code.

Here is the syntax for System.debug(). To display a message:

System.debug('Your Message');

To display the value of a variable:

System.debug(yourVariable);

To display a labeled value:

System.debug('Your Label: ' + yourVariable);

Use the Log Inspector

The handy Log Inspector exists to make it easier to view large logs! The Log Inspector uses log panel views to provide different perspectives of your code. Check it out by selecting Debug | View Log Panels.

Developer Console Basics (6)

The Debug | View Log Panels menu option is available only when you’re viewing a debug log tab. If, for example, you’re viewing the raw log tab, the option is grayed out.

Log panels change the structure of the log, to give other helpful information about the context for the code being executed. For example, different panels show the source, execution times, heap size, and calling hierarchy. (We know, more geek speak—this section is relatively technical. Remember, we’re getting to know the Developer Console, not the finer points of debugging. So if anything doesn’t make sense to you, try not to worry about it too much.)

These log panels interact with each other to help you debug your own code. For instance, when you click a log entry in the Execution Log or Stack Tree, the other panels (Source, Source List, Variables, and Execution Stack) refresh to show related information.

Developer Console Basics (7)

These panels are available in the Log Inspector.

  1. Stack Tree—Displays log entries within the hierarchy of their objects and their execution using a top-down tree view. For instance, if one class calls a second class, the second class is shown as the child of the first.
  2. Execution Stack—Displays a bottom-up view of the selected item. It displays the log entry, followed by the operation that called it.
  3. Execution Log—Displays every action that occurred during the execution of your code.
  4. Source—Displays the contents of the source file, indicating the line of code being run when the selected log entry was generated.
  5. Source List—Displays the context of the code being executed when the event was logged. For example, if you select the log entry generated when the faulty email address value was entered, the Source List shows execute_anonymous_apex.
  6. Variables—Displays the variables and their assigned values that were in scope when the code that generated the selected log entry was run.
  7. Execution Overview—Displays statistics for the code being executed, including the execution time and heap size.

What Is the Perspective Manager and How Can You Switch Perspectives?

A perspective is a layout of grouped panels. For instance, the predefined Debug perspective displays the Execution Log, Source, and Variables, while the Analysis perspective displays the Stack Tree, Execution Log, Execution Stack, and Execution Overview.

You can choose a perspective by selecting Debug | Switch Perspectives or Debug | Perspective Manager. Yes, it’s as easy as switching between different communication panels—and much easier than trying to decipher logs from your Mission Specialist, Earth Space Station, and Mars Mission Control all in the same view.

You can also create your own perspective. Configure your preferred combination of panels to display, and then select Debug | Save Perspective As. Enter a name for your perspective, and then click OK.

Manipulate Log Data to Find What You Need

You’re aware that Engine 3 has problems running smoothly at times. Having this engine running at capacity is critical as you steer to avoid asteroid 2014 QO441. But every time you try to run a systems check, you also get information from a depressed robot in your spaceship. It sends garbled reports predicting a robot uprising, increasing the number of lines in your log—and possibly making you miss valuable information.

You need a way to control the amount of information logged. Luckily for you, the Developer Console does just that with the help of log categories and log levels.

Log Categories

A log category is the type of information that is being logged.

Here are two common log categories.

  • ApexCode, which logs events related to Apex code and includes information about the start and end of an Apex method.
  • Database, which includes logs related to database events, including Database Manipulation Language (DML), SOSL, and SOQL queries (something we get into later).

Log Levels and How to Change Them

It seems that Engine 3 is having problems again. As you’re going through the logs to see what could have caused these problems, you see warning messages about the uprising from the melancholy robot.

One robot does not make an uprising, so you’re not too worried about the warnings. The faulty engine, however, is an urgent concern. What if you lose track of the actual messages from Engine 3 buried in all that log data? Log levels to the rescue!

Log levels control how much detail is logged for each log category. The following levels are available in the Developer Console, from the least amount of data logged (level = NONE) to the most (level = FINEST).

  • NONE
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • FINE
  • FINER
  • FINEST

Logging levels are cumulative. For instance, if the log level is INFO for an event, log information at the ERROR and WARN levels is also included. But if your log level is ERROR, you get only error messages. You don’t get warning messages or any other log information for that log category.

The information a log level provides also depends on the log event. Different log events start logging at particular log levels. For instance, some ApexCode events start logging at INFO. If you set ERROR as the log level, you don’t get any log information for those events.

To get the information you’re looking for, modify the log levels for different events. You want to suppress logging when the robot saves messages about the supposed uprising to the database. So, set the log level for the Database (DB) category to NONE or ERROR.

You can set these levels by selecting Debug | Change Log Levels.

Developer Console Basics (8)

On the General Trace Settings for You tab, click Add/Change (1). In the Change DebugLevel window, choose the log level for each category. Remember, use log levels judiciously. If your log level is FINEST (2), your code can hit log limits and take longer to run. Don’t worry if you don’t see all the levels when you update the log level for a category. Only the levels that add more logging for the category are listed.

Fortunately, once you’ve disabled logging for the robot’s warnings you find it easy to identify the problem with Engine 3: Its coolant level is low. You dispatch an engineer to add more coolant. While you’re at it, you ask the engineer to oil the robot’s joints. You hope that the fresh lubricant makes the robot a bit happier.

Resources

  • Salesforce Help: Logs Tab
  • Salesforce Help: Log Inspector
  • Salesforce Help: Debug Logs
Developer Console Basics (2024)

FAQs

What can you do with the developer console? ›

The Developer Console is an integrated development environment with a collection of tools you can use to create, debug, and test applications in your Salesforce org. The Developer Console can help with many of your development tasks.

Where is the developer console in Salesforce? ›

  1. To open the Developer Console from Salesforce Classic: Click Your Name , then click Developer Console.
  2. To open the Developer Console from Lightning Experience: Click the quick access menu ( ), then click Developer Console.

How do I navigate to developer console? ›

To open the developer console in Google Chrome, open the Chrome Menu in the upper-right-hand corner of the browser window and select More Tools > Developer Tools. You can also use Option + ⌘ + J (on macOS), or Shift + CTRL + J (on Windows/Linux).

What is the purpose of the developer console? ›

A developer console is a tool that logs information about the backend operations of the sites you visit and applications you run. The information logged in the console can help our developers to solve any issue that you may experience.

What does F9 do on Roblox? ›

Opening the Console

You can open Developer Console during a testing or a live experience session using any of the following ways: Press F9. Type /console into the chat.

Can you export from developer console? ›

In developer console switch from tr to table. Copy table's html and paste into notepad. save notepad as html and open it in a browser. you can easily copy your desired rows or whole result set from here.

How do I use developer console to query in Salesforce? ›

Step-by-Step Guide on How to Query Salesforce Database with SOQL
  1. Step 1: Access Salesforce Developer Console. ...
  2. Step 2: Identify the Object and Fields. ...
  3. Step 3: Select Relevant Fields. ...
  4. Step 4: Construct the SOQL Query (or Let Coefficient Do It for You) ...
  5. Step 5: Review and Execute (Seamlessly with Coefficient)
Mar 19, 2024

How do I test a code in Salesforce developer console? ›

Use the Developer Console to see additional information about your test execution:
  1. Open the Developer Console.
  2. Run your tests using the Apex Test Execution page.
  3. Check the Developer Console to step through the request.

How do I use developer tools console? ›

The simplest is to just right-click somewhere on the page and then select “Inspect Element” in the context menu that appears. You can also launch the developer console using a keyboard shortcut. The shortcut for most browsers on Mac is Command + Option + I, for Windows you can use Ctrl + Shift + I.

How do I arrange code in developer console? ›

Use the Source Code Editor: Open a working set of code files and switch between them with a single click. Format Your Code Files: You can use the Prettier code formatter to format your Aura components in Developer Console. To prettify the code in an open file, select Edit | Fix Code Formatting.

How do I see output in developer console? ›

Press Ctrl+Shift+J (Windows, Linux) or Command+Option+J (macOS). DevTools opens, with the Console open in the Activity Bar, displaying several types of values. Each type of result is displayed in a different way. Expand each output entry to analyze each result in more detail.

How do you find and replace in developer console? ›

Use Ctrl+F to open the Find bar. Use Ctrl+G for the next result. Use Ctrl+Shift+G for the previous result. Use Ctrl+Shift+F to open Replace.

How do I get developer console? ›

To open the developer console window on Chrome, use the keyboard shortcut Cmd-Shift-J on Windows or Cmd-Option-J on a Mac.

How do I give developer console access? ›

Here are the steps to add a user to your project on the Google Developers Console:
  1. Sign in to the Google Developers Console.
  2. Select a project.
  3. On the left menu, select Permissions.
  4. Near the top of your screen, select Add Member.
  5. Type the email address of the user you added to Play Console.
  6. Choose a permission level.

What is the developer tool console used for? ›

Developer Console is an embedded development environment with a set of instruments that you can use to build, debug, and test applications right in your browser. It records (or logs) the info associated with a web page, such as network requests, HTML, CSS, JavaScript, warnings and errors.

What is the purpose of the developer console in Roblox? ›

The console displays output messages from the client. If the console is accessed by the place's creator, the console also has a server tab in which it displays output messages from the server and allow the creator to run code from the server.

What is the purpose of the developer console in Android? ›

The Google Play Developer Console is your home for publishing operations and tools. Upload apps, build your product pages, configure prices and distribution, and publish. You can manage all phases of publishing on Google Play through the Developer Console, from any web browser.

How do you use the developer console in Subnautica? ›

Console Enable

To enable console commands, press the Shift key and Enter or `, (both buttons must be held at the same time) this should open the input box. To send a command, enter your desired command in the input box, and press enter.

References

Top Articles
Latest Posts
Article information

Author: Madonna Wisozk

Last Updated:

Views: 6511

Rating: 4.8 / 5 (48 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Madonna Wisozk

Birthday: 2001-02-23

Address: 656 Gerhold Summit, Sidneyberg, FL 78179-2512

Phone: +6742282696652

Job: Customer Banking Liaison

Hobby: Flower arranging, Yo-yoing, Tai chi, Rowing, Macrame, Urban exploration, Knife making

Introduction: My name is Madonna Wisozk, I am a attractive, healthy, thoughtful, faithful, open, vivacious, zany person who loves writing and wants to share my knowledge and understanding with you.