function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gabriel Corrêa de OliveiraGabriel Corrêa de Oliveira 

No long-lasting logs in

I am new to and I am still having a hard time to wrap my head around so many things.

In every "normal" production system, logs are constantly collected and kept for a reasonable amount of time according to a retention policy. Usually days or weeks. Thus, system administrators can monitor logs and detect potential problems before users even notice them.

However, with Salesforce, thinks seem to be very different:

Apparently logs will only be collected in a "per-session" basis and for a specific user. I can't find any practical way to generate logs for all the users of my "org" and retain them for any period longer than a few minutes.

My Salesforce "org" contains a lot of Apex code that interacts with external services and performs DML operations against "the database". Hence, there are many things that can go wrong during a normal business day for our users.

Alas, it seems that expects us to only collect logs to "debug" whatever goes wrong. Thus, we have to wait for a user to complain about something, enable the logs for his or her session, and ask him or she to reproduce whatever went wrong.

So, I wonder if this is really the best we can do with in terms of logging.

If so, it couldn't be more disappointing. I just can't believe that such a successful platform can have such a narrow-minded approach to logging.

Thank you.
Hi Gabriel

You are correct firstly that this is the way in which you have to do debuggging and logging on the platform. With most other production systems you are in control of the server and as such outputting all those logs is not as big an issue. Salesforce as a transactional systrem handles well in excess of 3 billion transactions on a daily basis which is almost unmaintainable as they would then need segmenting etc for the standard security provisions o Salesforce to enable this to happen.

For serious errors Salesforce will show a "GACK" error which is an internal error signifying something went wrong in Salesforce's underlying code and not yours. If you receive one of these contact Salesforce support and they will have logs around this to help avoid the mistake again. See this article ( for more information.

So how can we log for all of our users? There are solutions you can implement such as storing error traces as records within Salesforce itself that enable you to have a more thorough and granular log. This obviously requires you to have setup the error racing but that is expected in most other frameworks/platforms as well. Another option I have seen once is writing out errors and logs to an external source using callouts. Obviously as volumes increase this becomes problematic, but could still work for a smaller system. I personally often have many logs captured for a user's testing session to help find out errors and ensure code is thoroughly covered as this can help mitigate this problem longer term.

I hope that provides some clarity for you (although perhaps not the answer you wanted).