0

As per my current search, Salesforce Setup Audit Logs are stored automatically & we can't add any records to it manually when any apex is run or page is viewed or any custom object is added, updated or deleted. Please inform if any workaround is possible.

So to achieve that we might need to add a new custom object which will store our audit logs. Please inform if anyone has any better approach.

If we need to use a custom object to add logs, we can setup triggers if any custom object is added or updated. But how can we log following?

  • If any user login or logout
  • If any community user login or logout from community
  • If any user view salesforce standard object list or details page

3 Answers 3

2

This is a good use case for using Event Monitoring functionality provided by Salesforce.

Refer Get Started with Event Monitoring

Event monitoring provides tracking for lots of types of events, including:

  • Logins
  • Logouts
  • URI (web clicks in Salesforce Classic)
  • Lightning (web clicks, performance, and errors in Lightning Experience and the - Salesforce mobile app)
  • Visualforce page loads
  • API calls
  • Apex executions
  • Report exports
3
  • Salesforce retains only data of last 1 day, is it correct? If yes, then how to see/show previous logs before 1 day? Sep 3, 2018 at 12:05
  • No, Salesforce retains 30 days Sep 3, 2018 at 12:47
  • Article says they can retain data for 30 days at an additional cost. Any idea how much? If I have created custom pages for custom object list & add/edit, will it track them as well? Since it only retains last 30 days data at an additional cost, isn't it would be easier & cheaper to create custom object & store unlimited data? Sep 4, 2018 at 5:13
1

What you're looking for is event monitoring. It can track most of the meta-events you're looking for. Note that logout events are unreliable, as a user can terminate their session without explicitly logging out by simply closing their browser.

2
  • Article says they can retain data for 30 days at an additional cost. Any idea how much? If I have created custom pages for custom object list & add/edit, will it track them as well? Since it only retains last 30 days data at an additional cost, isn't it would be easier & cheaper to create custom object & store unlimited data? Sep 12, 2018 at 9:32
  • @ShivangiPatel Yes, if you built something custom, you'd get unlimited monitoring. Of course, it can't detect all possible situations, either, but the trade off is that you get unlimited storage, as you've observed.
    – sfdcfox
    Sep 12, 2018 at 12:55
0

The process of how to built out the custom object option is outlined here which we are going to implement due to budget constraints: https://www.machinereadablepeople.net/home/2016/10/21/auditing-when-a-salesforce-record-is-viewed

2
  • 1
    Welcome! Since links can break it's always best to include a summary or relevant pieces of the steps directly in your answer. Mar 1 at 11:17
  • Welcome to Salesforce Stack Exchange (SFSE)! Link-only answers are discouraged, and may be deleted. (See: Why and how are some answers deleted?) Please edit you answer to add more information. (From How do I write a good answer?: "...please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link.... ")
    – Moonpie
    Mar 1 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.