jongpie / NebulaLogger

The most robust observability solution for Salesforce experts. Built 100% natively on the platform, and designed to work seamlessly with Apex, Lightning Components, Flow, OmniStudio, and integrations.
https://nebulalogger.com
MIT License
713 stars 166 forks source link

Add configurable rules for advanced log retention policies #226

Open jongpie opened 3 years ago

jongpie commented 3 years ago

Hey, @jongpie we discussed cases where we use the logger and came up with a similar idea. Potentially we will create a lot of logs per day and in most cases, they aren't really relevant to be stored for always. We looked into your Batch Deletion feature. But as far as we understand the feature does delete all logs after x days regardless of whether there is only info, an error, or in which context the log was created. What are your thoughts on setting up multiple retention rules depending on the scenario and included error?

For example:

  • We have feature A which is very important. Logs of this feature must not be deleted at all.
  • For Feature B we want to see the logs for 5 days. Then they can be deleted. Except there was an error. Then they should be deleted after 30 days.
  • Feature C isn't really important. Logs should be deleted after 3 days.

All of the features have an identifier using the scenario field. And then there could be a custom metadata type where you can define a scenario, a retention day, and whether error logs should be skipped. For all logs without any scenario, you can have a default setting.

We probably will develop such a feature, but wanted to discuss it with you before. Maybe you say, that it might be relevant in general, then we can find some synergies.

Originally posted by @fentes in https://github.com/jongpie/NebulaLogger/discussions/207#discussioncomment-1459571

fentes commented 2 years ago

Hey @jongpie,

as promised, I wanted to share my feedback to the new plugin. Currently we have the issue, that the rules are not working (see #354 ), but a few weeks ago I was able to test it and there it was working.

In general, this feature is amazing and really helps to keep overview of everything and not blowing up the database with tons of logs. Since we are logging user inputs as part of the customer community, we need to keep these logs forever, if there are any discussions with user. But other logs are just interesting for debugging purposes and can be deleted aber some days.

Together with the rest of my team, we brainstormed about setting up the rules:

Currently we don't completly understand all capabilities of this tool. Maybe you can give some insights, of what is possible 😉

jongpie commented 2 years ago

Hi @fentes - this is some incredible feedback, thanks so much for brainstorming with your team & sharing everyone thoughts! I have a couple of follow up thoughts & questions for you & your team

Regarding your other questions, I've added my responses below each question - hopefully this format is readable, but let me know if you have any follow up questions

Thanks again for all of your feedback!

fentes commented 2 years ago

Hey @jongpie,

jongpie commented 2 years ago

@fentes thanks for the feedback! I'm going to try to do 3 things:

  1. Over the next few weeks, I'm going to try to fix the existing implementation so that it works as intended (to resolve #354)
  2. I'll also try to make some small enhancements to support more trigger events (at least BEFORE_UPDATE and/or AFTER_UPDATE), and try to add support for additional objects like LogEntryTag__c
  3. Over the next few months, I'm going to see about eliminating LogRetentionRuleCondition__mdt altogether, and instead changing the implementation to use a single field on LogRetentionRule__mdt to specify SOQL-style filtering syntax (like @jamessimone does for Apex Rollup). This will be a fairly complex change, but I'd like to try to at least create a proof of concept of this idea, as I think this would be a nicer setup.

I have a few other releases that I need to finish before I can work on this, but I'll keep you updated on my progress.

And since we're having some great discussions here, I'm re-opening this issue for now - I'll close it again once I've implemented some of the above items.