NebulaLogger
NebulaLogger copied to clipboard
Is it possible to configure the Logger to only do System.debug()?
Package Edition of Nebula Logger
Unlocked Package
Package Version of Nebula Logger
4.6.16
New Bug Summary
I'm having issues with the Logger generating too many SOQL queries, or too many platform events, as part of test coverage. Is it possible to configure Logger to only do System.debug(), and not create records and not generate platform events?
Hi @mikesobczak - could you provide some more details on how you're using Nebula Logger? It looks like you're using a fairly old version of the package, but even so, it should only use 3-4 queries max. And could you share the error you receive about too many platform events?
I setup my test coverage to configure the Logger to use the following:
config.IsEnabled__c = true;
config.LoggingLevel__c = 'INFO';
config.DefaultSaveMethod__c = 'SYNCHRONOUS_DML';
Here's a stack trace from my test method:
15:41:14.344 (13864258581)|FATAL_ERROR|System.LimitException: Too many SOQL queries: 101
Class.LogEntryEventHandler.getRecentLogWithApiReleaseDetails: line 391, column 1
Class.LogEntryEventHandler.upsertLogs: line 56, column 1
Class.LogEntryEventHandler.executeAfterInsert: line 47, column 1
Class.Logger.saveLog: line 2572, column 1
Class.Logger.saveLog: line 2502, column 1
Class.RSBackend.defaultFinally: line 1250, column 1
We are using unlocked package version 4.6.16
Interesting, I don't normally recommend using 'SYNCHRONOUS_DML' in most cases, as that will cause more code & queries to run synchronously. Is there a reason you're using it?
And if you want to disable publishing of the platform events, you can try using config.DefaultSaveMethod__c = null
instead, I think that would work on v4.6.16
- new versions of Nebula Logger have a field called IsSavingEnabled__c
that can be set to false
, but that's not available in the version that you're using (you may want to consider upgrading at some point).
I had been using EVENT_BUS, but was exceeding the test coverage limit of 500 platform events.
Unfortunately, Default Save Method is a required field in the version I'm running. I can't set it to null.
@mikesobczak just to clarify on your scenario, when using EVENT_BUS
, are you expecting there to be 500+ log entries created within your test method(s)? I'm not sure what your code is doing, but since you're using LoggingLevel__c = 'INFO'
, having 500+ entries generated seems like a lot, I'd be interested in hearing more about your use case.
As far as next steps, I think your best option is to upgrade Nebula Logger so you can leverage the new field LoggerSettings__c.IsSavingEnabled__c
, it would provide the exact functionality you're looking for.
Following up on this, I'm planning to look into the limit of 500 platform events as part of issue #351 - I'm going to go ahead and close this issue, but @mikesobczak please let me know if you have any follow up questions!