FCORE_BASE.Logger is the Platform package’s structured logger, available to every package under the FCORE_BASE namespace. It provides structured logging for exceptions, custom messages, and HTTP callouts. Each log persists to the Log__c object.
A log is collected in memory and then committed in one of two ways:
- By DML — written directly to
Log__cin the current transaction. - By platform event — published as a
Log_Event__eplatform event, which a subscriber persists. Because the platform event is delivered independently of the current transaction, this option survives a rollback. Use it whenever the surrounding transaction may roll back (for example, when you log an exception and then rethrow it).
Boolean shouldCommitByDML argument: pass true to commit by DML, or false to commit by platform event.
Log Levels
The level is theFCORE_BASE.Logger.LogLevel enum:
Always Set the Execution Context First
CallFCORE_BASE.Logger.setApexExecutionContext(Type classType, String methodName) before you log so that the originating class and method are recorded on the log:
Methods
AllLogger methods are global static.
The message overload of
log requires the fourth action argument — there is no three-argument message overload. The logWithContext correlation variant exists only for an Exception (there is no message or callout overload).Collect Versus Commit
The plainlog(...) overloads only collect a log in memory; nothing is written until you call commitLogs(Boolean shouldCommitByDML). This lets you batch several logs and flush them once. The logAndCommit(...) overloads collect and commit in a single call.
Inner Classes
Logger.CalloutLogWrapperwraps an HTTP request/response pair so you can log the request and response bodies and the status. Construct it withCalloutLogWrapper(HttpRequest request, HttpResponse response), then pass it to a calloutlogorlogAndCommitoverload.Logger.LogContextis returned by the...WithContextmethods. It carries auuidString you can hand back to a user or to another system so they can correlate that reference with the storedLog__crecord.

