You need to sign in to do that
Don't have an account?
Can't see System.debug() output in installed managed package
Hi,
We have an application that we distribute as a managed package. In the dev org where I created the package, I can see all output from my System.debug() calls in the system log window.
When we install the package in a client's SF org, we can't see any of the System.debug() output. We do see the SF profiling information, but no debug() calls.
I can't find any reference to this in the documentation.
- Is this known behavior?
- Is there some way to enable System.debug() output in a managed package?
thanks for any feedback,
joezaloom
Apex Code Development
All Answers
Managed packages are very hard to troubleshoot without logs.
public static void logMessageWithSOQL(String message) { // Sanitize the message to remove invalid characters String sanitizedMessage = sanitizeForSOQL(message); // Construct the SOQL query String queryString = 'SELECT Name FROM PermissionSet WHERE Name LIKE \'' + sanitizedMessage + '\' LIMIT 1'; // Execute the query List<PermissionSet> results = Database.query(queryString); } private static String sanitizeForSOQL(String input) { if (String.isEmpty(input)) { return ''; } // Replace new lines with space String sanitized = input.replace('\n', ' ').replace('\r', ' '); // Replace single quotes (common SOQL injection risk) sanitized = input.replace('\'', '\\\''); // Remove non-alphanumeric characters except underscores, percent signs, // spaces, parentheses, and dots // Adjust the regex to include these additional characters sanitized = sanitized.replaceAll('[^\\w%()\\.\\s]', ''); return sanitized; }Example of logs for troubleshooting (filter by SELECT Name FROM PermissionSet):
10:52:24.0 |SOQL_EXECUTE_BEGIN|SELECT Name FROM PermissionSet WHERE Name LIKE 'Before send()
10:52:24.0 |SOQL_EXECUTE_BEGIN|SELECT Name FROM PermissionSet WHERE Name LIKE 'After send()
10:52:24.0 |SOQL_EXECUTE_BEGIN|SELECT Name FROM PermissionSet WHERE Name LIKE 'Before getBody (MRA_Http_Util)' LIMIT 1
10:52:24.0 |SOQL_EXECUTE_BEGIN|SELECT Name FROM PermissionSet WHERE Name LIKE 'After getBody (MRA_Http_Util)' LIMIT 1
Thank you!
Daniel