Have you heard that logging is repetitive or indecipherable? At first glance, logging might be intimidating, but thanks to the Developer Console Log Inspector, you can turn even the longest logs into poetry – or whatever you want.

This post shows how to use the Developer Console Log Inspector (Summer ’13) to view and filter logs, and includes a simple example. Please share your own poetry!

In the Developer Console, click Debug > Open Execute Anonymous Window (or Ctrl/E) and enter the following Apex code:

List<String> characters = new List<String>{'child', 'little white dog', 'little green frog', 'butterfly'};

String spacing(integer num) {
String spacing = '';
for (integer i = 0; i < num * 5; i++) {
   spacing += '_';
   }  
      return spacing;
   }

void startPoem()
{
   writePoem(0, 'A child');
}

void writePoem(integer position, String prefix)
{
   String character = characters[position];

   if (++position < characters.size())
   {
      system.debug(spacing(position - 1) + prefix + ' couldn\'t sleep, so the ' + character + ' sang a song about a ' + characters[position] + ' ');  
      writePoem(position, 'who');
   }
   else if (position == characters.size())
   {     
      system.debug(spacing(position) + '...who fluttered in the sky');
   }

   system.debug(spacing(position - 1) + '...and the ' + character + ' fell asleep');
}

startPoem();

Select the Open Log option and click Execute.

Developer Console - Execute Anonymous Window

The log opens in the Log Inspector, in the Log Only perspective. At first, it includes a bunch of limits information and system messages:

Log Inspector - Execution Log Panel - All Messages

The options at the bottom of the panel allow you to filter the messages displayed. Select Debug Only and watch poetry happen:

Developer Console - Log Inspector - Debug Only

You can still use the Developer Console to debug and troubleshoot – new Log Inspector features make that even easier. For example, click Ctrl/P to select from the available log panels and create custom perspectives. (In this image, the Execution Log panel is not available because it is the only panel selected and you can’t have a perspective without any panels.)

Developer Console - Log Inspector - Select Panels

 

 

For more information on the Log Inspector and log perspectives, check out the Developer Console online help – it’s updated and improved too!

tagged , , , , Bookmark the permalink. Trackbacks are closed, but you can post a comment.
  • Saravanan Selvamalar

    Hi,

    In my bottom panel I can’t able to see the Debug only Check box .Could any one help me how can enable the check box.

    • http://twitter.com/ReidCarlberg Reid Carlberg

      Are you in a Summer 13 preview org?

      • Saravanan Selvamalar

        Sorry Reid,

        Still I am in Spring 13 not Summer. Based on logo I get to know.

        • Jennifer Shipman

          You can still filter the log – just type “DEBUG” in the filter field.

          • Saravanan Selvamalar

            Thanks ..

  • Anonymous

    Nice Tips

  • http://twitter.com/SFDC_Developer Mitesh Sura

    looking forward to new DC in my production org.

  • Anonymous

    the usability of new logging panel at the end of screen is little strange since in previous version of debug console its on top as most developers are used too, but It seems the new ui is modeled based on eclipse like ui style but which is better as the debug console evolves as an alternative tool in long term!

    • Jennifer Shipman

      The Log Inspector is still in the top panel, but there are lots of other changes in the new UI …

    • Jennifer Shipman

      The Log Inspector is still in the top panel, but there are lots of other changes in the new UI …

  • Jackdon Wang

    If you can’t see the log ,you can reopen the Developer Console