8

I spend my days waiting on the Force.com Console and it makes me crazy, I have a pretty nice machine and it still chokes on the details sometimes.

Anyways, I saw Loggly had given a presentation at DF '11 and is presenting again this year Dreamforce '12.

However, it seems like they're presentation is targeted at using their product, or for that matter others like it (SumoLogic, Splunk) on Heroku, and not really targeting APEX/VisualForce development!

Is this the case? Are there any better solutions out there for reviewing logs?

Are there any APIs that allow you to export your debug logs out of SFDC programatically? Or has anyone even tried to tackle this?

2
  • Can you please let me know how are you getting the contents of the debug log page ? I have been using this : https://{server}/secur/Frontdoor.jsp/?sid={sessionId}/{apexlogurl} when I try to read the page contents I get a "Javascript not enabled" message in the read content! Can you please explain me what is wrong here ?
    – user2716
    Apr 20, 2013 at 10:55
  • IlluminatedCloud and IntelliJ Idea with the integrated Offline debugger is great for reviewing logs and stepping through code and the log in context to debug
    – Eric
    Aug 30, 2017 at 3:50

10 Answers 10

18

I've been working on a tool that allows you to export the apex logs and then gives you some basic highlighting, searching and filtering options. I often end up working with logs closer to 2 MB in size and needed a way to quickly filter out just the USER_DEBUG messages.

FuseIT SFDC Explorer is .NET based and currently only runs on Windows. It is still in beta (the kind of beta where there are still sharp edges that you could cut yourself on. I.e. don't be surprised if it crashes occasionally).

The screen shots on the web site are a bit out of date. What I often do is bring the Force.com console up to ensure that it is polling and capturing the logs. Then I can use the Refresh and Open Log buttons on the Apex Logs tab to open up the required log.

FuseIT SFDC Explorer

Once you have a log open you can use the checkboxes in the left Apex Log area to show/hide only certain events. Alternatively, you can right click on an event in the log to hide it from there.

FuseIT SFDC Explorer Toggle Raw/Grid Log

If you just want a quick way to download the raw log then you can toggle the view to just show the log text. There is a copy log to clipboard button if you just want to grab the whole thing to paste into the editor of your choice. The paste allows you to drop in partial logs or logs copied out of Force.com explorer.

6
  • awesome!!! how do you get the logs out of Force.com? Do you capture the responses to the browser? Aug 9, 2012 at 21:31
  • 1
    @jordan.baucke I use the SOAP API to query the ApexLog to get the Ids. Then I create a call to to the Salesforce front end website to download the log content by setting the request headers with the session Id. Aug 9, 2012 at 21:49
  • clever that's def. awesome! Aug 9, 2012 at 22:15
  • Is there any way to pull in all user logs not just the logged in one? Feb 27, 2014 at 6:06
  • @DanielSokolowski Sure, just adjust the filtering on the LogUserId column. Or are you referring to the FuseIt SFDC explorer explicitly? Feb 27, 2014 at 18:38
6

Agreed that the ExtJS console needs a lot of work. anything halfway complex will bring the interface to its knees. I have settled into a groove of running unit tests from the website and downloading the log, or copying and pasting the raw log into Notepad++, once there its a 2 click operation to find the lines with this regular expression "USER_DEBUG|FATAL|MAXIMUM DEBUG|Op:|SOQL_EXECUTE_BEGIN|SOQL_EXECUTE_END" and then press "Find All in Current Document"

That brings up a list of matching lines below that you can double click on to navigate through the log without making your eyes bleed.

Search "USER_DEBUG|FATAL|MAXIMUM DEBUG|Op:|SOQL_EXECUTE_BEGIN|SOQL_EXECUTE_END" (505 hits in 1 files)
C:\Downloads\apex (33).log (505 hits)
Line 208: 00:06:53.652 (6652739000)|USER_DEBUG|[13]|DEBUG|org: 00DM0000000Br5EMAS
Line 261: 00:06:53.698 (6698356000)|USER_DEBUG|[67]|DEBUG|setting ProjectID = 21060077
2
2

What browser are you using?

I gave up using anything other than Chrome with the Developer Console. It's the only browser that I got any sort of decent response.

It still can be a bit glitchy now and then, but it's hands down better than IE or FF performance.

As for exporting your debug logs - There's no Download option anymore (sigh)... I did find that if you select the desired log and then click the "Open Raw Log" button you get a version that will copy and paste nicely into Notepad++

I often do this for the big logs simply because it's more responsive to my filter and search requests.

7
  • yeah I'm using Chrome, I found it more responsive actually than FF (on Windows) ... just recently switched to OSX so maybe I need to play with it. Aug 9, 2012 at 20:00
  • Chrome is the fastest browser to use with the Developer Console but occasionally has issues with scrolling. Firefox generally doesn't have the scrolling issue or issues with expanding trees (such as when exmaning a heap dump) but occasionally it fails to load large heap dumps. Unfortunately IE9 appears to be the most functional with the developer console, but Chrome is the fastest if you avoid functionality that causes issues. Aug 9, 2012 at 20:43
  • The biggest frustration for me are the debug log size limits. With anything moderately complicated your log gets truncated if Apex Code logging is set to Debug or finer, especially when testing large record batches (200 records at a time). Aug 9, 2012 at 20:44
  • @Wilburn, cut down on the log levels. I usually override the default settings per apex file to set DEBUG on apex and NONE on everything else.
    – ebt
    Aug 9, 2012 at 20:58
  • OR put log levels on APEX to INFO and add system.debug(LoggingLevels.INFO,'I made it'); to cut down on a majority of the log spam.
    – ebt
    Aug 9, 2012 at 21:05
1

I'm going to post this to one other question. But here's a quick script that downloads all logs to a "log" subdirectory.

#!/bin/bash

# script for export ALL debug logs to a subdirectory
# named "log".  
#
# it requires the "force" CLI tool be available and
# assumes the user is already logged in.
#
# Sure, I could have added more debugging, like checking
# to see if the user was logged in, but I didn't have 
# all night. ;-)
#
# 2017-08-29 [email protected]

for each in $(force query "select id from apexlog"); do
    log=$(echo $each | sed -e 's/"//g')

    if [ "$log" == "Id" ]; then
        echo "ignoring $log"
        continue
    fi

    echo "writing log/$log.debug"
    force log $log > log/$log.debug
done
1
  • I receive an error: line 11: force: command not found
    – Patlatus
    Jun 24, 2021 at 12:47
1

In case someone is still looking for this answer in 2022, this simple bash script I wrote will retrieve all logs and dump them into a directory called 'logs'.

ORG_ALIAS=xxx

for logline in $(sfdx force:apex:log:list -u $ORG_ALIAS); do 
  if [[ $logline == 07L* ]]; then 
    echo $logline
    sfdx force:apex:log:get -u $ORG_ALIAS -d logs -i $logline
  fi
done

Don't forget to change ORG_ALIAS to your org's respective alias.

0

I use Sublime Text 2 with a customized plugin.

https://github.com/mdenavacelle/SublimeApexLogReader

Grabs all debug logs with a keyboard shortcut.

0

Now can be done in Visual Studio Code with the Salesforce Extension Pack installed, just select "SFDX: Get Apex Debug Logs" from the command palette.

VS Code Screenshot

0

Now we can download logs from Logs window in dev console. Right-click on any log in Logs section on bottom side and it gives an option to open the raw file or to download log.

0

I'm a part of a team that has been working on Maven Tools for Salesforce, a Google Chrome extension that offers you a collection of Salesforce developer tools and it can help you with this issue.

With Maven Tools you can open, search, delete and export multiple apex debug logs at once. As you can see in the screenshot below, you can select multiple logs and export them by clicking the export button. Logs will be exported in a zip file with each log being exported into a separate .txt file.

enter image description here

0

Assuming you have a valid sfdx session and jq installed, this one liner will download all your logs to your home/downloads/logs folder.

sfdx force:apex:log:list --json | jq  -r '.result[].Id' | \
while IFS= read -r id; do sfdx force:apex:log:get -i $id > \ 
~/Downloads/logs/$id.log; \
done

You must log in to answer this question.

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