Monitor Debug Logs. salesforce Salesforce Organization
Oglas
Oglas
Set Up and Maintain Your Salesforce Organization Monitor Debug Logs
Monitor Debug Logs
Set trace flags to trigger logging for users, Apex classes, and Apex triggers in the Developer Console or in Setup. Monitor the resulting logs to diagnose problems in your org.
You can retain and manage debug logs for specific users, including yourself, and for classes and triggers. Setting class and trigger trace flags doesn’t cause logs to be generated or saved. Class and trigger trace flags override other logging levels, including logging levels set by user trace flags, but they don’t cause logging to occur. If logging is enabled when classes or triggers execute, logs are generated at the time of execution.
IN THIS SECTION:
To activate debug logging for users, Apex classes, and Apex triggers, configure trace flags and debug levels in the Developer Console or in Setup. Each trace flag includes a debug level, start time, end time, and log type. The trace flag’s log type specifies the entity you’re tracing.
The debug log contains information about each transaction, such as whether it was successful and how long it took. Depending on the filters set by your trace flags, the log can contain varying levels of detail about the transaction.
EDITIONS
Available in: Salesforce
Classic
Available in Enterprise,
Developer, Performance,
Unlimited, and
Database.com Editions
The Salesforce user interface and Email Services are not available in Database.com.
USER PERMISSIONS
To view, retain, and delete debug logs:
•
“Manage Users”
SEE ALSO:
Set Up Debug Logging
To activate debug logging for users, Apex classes, and Apex triggers, configure trace flags and debug levels in the Developer Console or in Setup. Each trace flag includes a debug level, start time, end time, and log type. The trace flag’s log type specifies the entity you’re tracing.
You can retain and manage debug logs for specific users, including yourself, and for classes and triggers. Setting class and trigger trace flags doesn’t cause logs to be generated or saved. Class and trigger trace flags override other logging levels, including logging levels set by user trace flags, but they don’t cause logging to occur. If logging is enabled when classes or triggers execute, logs are generated at the time of execution.
The following are the limits for debug logs.
•
Each debug log must be 2 MB or smaller. Debug logs that are larger than 2 MB are reduced in size by removing older log lines, such as log lines for earlier
System.debug
statements.
The log lines can be removed from any location, not just the start of the debug log.
•
Each org can retain up to 50 MB of debug logs. Once your org has reached 50 MB of debug logs, the oldest debug logs start being overwritten.
EDITIONS
Available in: Salesforce
Classic and Lightning
Experience
Available in: Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
USER PERMISSIONS
To view, retain, and delete debug logs:
•
“Manage Users”
Configure Trace Flags in the Developer Console
To configure trace flags and debug levels from the Developer Console, click Debug > Change Log Levels. Then complete these actions.
•
To create a trace flag, click Add.
747
Set Up and Maintain Your Salesforce Organization Monitor Debug Logs
•
To edit an existing trace flag’s duration, double-click its start or end time.
•
To change a trace flag’s debug level, click Add/Change in the Debug Level Action column. You can then edit your existing debug levels, create or delete a debug level, and assign a debug level to your trace flag. Deleting a debug level deletes all trace flags that use it.
Create Trace Flags in Setup
1. From Setup, enter
Debug Logs
in the
Quick Find
box, then click Debug Logs.
2. Click New.
3. Select the entity to trace, the time period during which you want to collect logs, and a debug level. A debug level is a set of log levels for debug log categories: Database, Workflow, Validation, and so on. You can reuse debug levels across your trace flags.
View, Edit, or Delete Trace Flags in Setup
To manage trace flags from Setup, complete these actions.
1. Navigate to the appropriate Setup page.
•
For user-based trace flags, enter
Debug Logs
in the
Quick Find
box, then click Debug Logs.
•
For class-based trace flags, enter
Apex Classes
in the
Quick Find
box, click Apex Classes, click the name of a class, then click Trace Flags.
•
For trigger-based trace flags, enter
Apex Triggers
in the
Quick Find
box, click Apex Triggers, click the name of a trigger, then click Trace Flags.
2. From the Setup page, click an option in the Action column.
•
To delete a trace flag, click Delete.
•
To modify a trace flag, click Edit.
•
To modify a trace flag’s debug level, click Filters.
•
To create a debug level, click Edit, and then click New Debug Level.
748
Set Up and Maintain Your Salesforce Organization Monitor Debug Logs
Configure Debug Levels in Setup
To manage your debug levels from Setup, enter
Debug Levels
in the
Quick Find
box, then click Debug Levels. To edit or delete a debug level, click an option in the Action column. To create a debug level, click New.
Collect Debug Logs for Guest Users
Your public users generate a large volume of events, which can quickly fill up your debug logs. For this reason, logs are collected for site visitors who are using your Guest User license only when a public user’s browser has a special cookie. Logging of public users’ asynchronous activity isn’t available because asynchronous requests don’t include browser cookies.
To enable logging for a guest user’s synchronous activity:
1. Ask the user to set a browser cookie with a domain of
.force.com
, a name of debug_logs
, and any value. (If you use a custom domain, ask your user to set the cookie for your domain rather than for
.force.com
.) Refer to the documentation for your user’s browser for information on adding cookies. To add cookies, your user probably needs a browser plug-in or extension for web development.
•
To set a cookie for API requests made with Java code, use the
URLConnection
class and set the cookie value as follows.
–
If you use a
.force.com
domain, use this code.
URL url = new URL("http://
yourSite
.force.com/");
URLConnection con = url.openConnection(); con.setDoOutput(true); con.setRequestProperty("Cookie", "debug_logs=debug_logs,domain=.force.com"); con.setRequestProperty("Content-Type", "text/plain; charset=utf-8"); con.connect();
–
If you use a custom domain (for example, yourCustomDomain.com
), use this code.
URL url = new URL("http://
yourCustomDomain.com
/");
URLConnection con = url.openConnection(); con.setDoOutput(true); con.setRequestProperty("Cookie", "debug_logs=debug_logs,domain=.force.com"); con.setRequestProperty("Content-Type", "text/plain; charset=utf-8"); con.connect();
•
To set a browser cookie in Google Chrome
™
:
a. Navigate to your site.
b. Open the Chrome DevTools Console by pressing Ctrl+Shift+J (Cmd+Opt+J on macOS).
c. Execute a command to set the cookie.
749
Set Up and Maintain Your Salesforce Organization Monitor Debug Logs
–
If you use a
.force.com
domain, use this command.
document.cookie="debug_logs=debug_logs;domain=.force.com";
–
If you use a custom domain (for example, yourCustomDomain.com
), use this command.
document.cookie="debug_logs=debug_logs;domain=
yourCustomDomain.com
";
•
To set a browser cookie in other browsers, install a plug-in or extension.
2. Find the name of your site’s guest user.
a. From Setup, enter
Sites
in the
Quick Find
box, then select Sites.
b. Select your site from the Site Label column.
c. Select Public Access Settings > View Users.
3. Set a user-based trace flag on the guest user.
a. From Setup, enter
Debug Logs
in the
Quick Find
box, then click Debug Logs.
b. Click New.
c. Set the traced entity type to User.
d. Open the lookup for the Traced Entity Name field, and then find and select your guest user.
e. Assign a debug level to your trace flag.
f. Click Save.
Tip: Debug logs are for live troubleshooting. To record all site traffic, use event monitoring. For details, see the Sites section of
SOAP API Developer Guide: EventLogFile .
SEE ALSO:
View Debug Logs
USER PERMISSIONS
To use the Developer Console:
To save changes to Lightning resources:
“View All Data”
To execute anonymous Apex:
To use code search and run SOQL or SOSL on the query tab:
“Author Apex”
“API Enabled”
To save changes to Apex classes and triggers:
To save changes to Visualforce pages and components:
“Author Apex”
“Customize Application”
“Customize Application”
EDITIONS
Available in: Salesforce
Classic and Lightning
Experience
Available in: Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
750
Prenesi
Oglas