Program for easily extracting Salesforce error/debug logs and setting debug traceflag for any user within org.
- enable debug trace logs for any user in an org
- automatically remove debug files to avoid space limitations
- compressing files in zip format so they can be bundled shared
- (Docker) -nginx web server to host files https://docs.docker.com/
To get a local copy up and running follow these simple steps.
Confirm you're authenticated with the Salesforce instance you're extracting the logs. This can be verified by running sfdx force:org:list
- Clone the repo
git clone https://github.com/michael-adam-sheehan/salesforce-errorlog-extractor.git
- Run docker-compose and substitute your target org username. (Note: the following command will extract the authenticated url from your credentials tp setup the docker image)
TARGET_USERNAME="[email protected]" && docker-compose build --force-rm --build-arg TARGET_USERNAME=$TARGET_USERNAME --build-arg SFDX_AUTH_URL=$(sfdx force:org:display --verbose -u $TARGET_USERNAME --json | grep "sfdxAuthUrl" | sed -E 's/^.*(force:[^"]+).*$/\1/') web
- Start up the container.
docker-compose up -d
- Either login to the container or run the following command to execute the program.
docker exec -it sfdc-errorlog-extractor python3 -m sfdc_errorlog_extractor -u [email protected] -d [email protected] --no-traceflag --delete-logs
- Verify you have Python3 installed.
python --version
- It's recommended to run this within a virtualenv (https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/) but not required. Typical usage would be
virtual venv && source ./venv/bin/activate
. This creates a subdir called venv for python libs and starts it w/activate. - Run program and choose your options. The following command grabs all of the logs from someuser fom the user that authenticated and doesn't set the Trace Debug Flag and removes all logs for this user on theinstance.
python -m sfdc_errorlog_extractor -u [email protected] -d [email protected] --no-traceflag --delete-logs
errorlog-extraction.py [--no-traceflag --delete-logs --verbose --compress] -u <targetusername> -d <debugusername>
Required Fields
-u => username you're authenticated with
-d => username you want to extract logs for and set debug trace for if enabled
Optional Fields
--no-traceflag => does not set the debug trace flag for a user. The default is to set the debug traceflag for a user if the traceflag isn't expired.
--delete-logs => removes the users' logs from the instance freeing up the log storage space
--compress => compresses the logs into a zip format
Snippet of the program extracting the logs via a Docker container, removing them from the instance and making them available via a nginx web browser.
Mike Sheehan- @twitter_handle - [email protected]