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
Adam BengtsonAdam Bengtson 

Creating a log file in Apex

I have a visualforce page that talks to an Apex class.  I would like to log errors in a separate file that will allow me to check at anytime the errors we have encountered.  How would I implement this in Salesforce?
Best Answer chosen by Adam Bengtson
SalesFORCE_enFORCErSalesFORCE_enFORCEr
We use a custom object and anytime there is an error/exception in the code we catch it and create a record in that custom object with details like Class/Method Name, Line number, Error message etc.

All Answers

SalesFORCE_enFORCErSalesFORCE_enFORCEr
We use a custom object and anytime there is an error/exception in the code we catch it and create a record in that custom object with details like Class/Method Name, Line number, Error message etc.
This was selected as the best answer
Adam BengtsonAdam Bengtson
Thanks I'll do it this way, makes sense.
SalesFORCE_enFORCErSalesFORCE_enFORCEr
On top of that, we have created workflow rule to notify admins and developers whenever a new record is created in this object.