Codeunit 70623694 EOS004 App Logger
Provides a framework for logging messages from apps to multiple underlying loggers.
procedure Reset()
Resets the logger, removing all configuration and cached data.
procedure Initialize(AppId: Guid; Category: Text): Boolean
Initializes the logger with the specified app and category. This replaces all currently cached loggers with the configured ones.
AppId Guid
The app id.
Category Text[]
The category.
Returns Boolean
true
if the logger was actually initialized, false
if it already was initialized.
procedure ClearLoggers()
Removes all loggers from the list of loggers.
procedure AddLogger(LoggerType: Enum "EOS004 App Logger Type"; ServiceConfigCode: Code[20]; DiagnosticsKey: Text[64])
Creates, initializes and then adds a logger of the given type and the given service configuration to the list of loggers.
LoggerType Enum "EOS004 App Logger Type"
The type of logger to add.
ServiceConfigCode Code[20]
The service configuration code for the logger to add.
DiagnosticsKey Text[64]
The diagnostics key for the logger to add.
procedure AddLogger(Logger: Interface "EOS004 IAppLogger")
Manually adds the given logger to the list of loggers. This logger is expected to be already initialized.
Logger Interface "EOS004 IAppLogger"
The logger to add.
procedure AddApplicationInsights(ConnectionString: Text; DiagnosticsKey: Text[64])
Manually adds an Application Insights logger to the list of loggers. This requires the current instance to be initialized first.
ConnectionString Text[]
The connection string for the Application account.
DiagnosticsKey Text[64]
The diagnostics key to use.
procedure Initialize(App: ModuleInfo; Category: Text): Boolean
Initializes the logger with the specified app and category. This replaces all currently cached loggers with the configured ones.
App ModuleInfo
The app.
Category Text[]
The category.
Returns Boolean
true
if the logger was actually initialized, false
if it already was initialized.
procedure AutoFlushLimit(): Integer
Specifies whether the logger should automatically flush after a certain number of log entries.
Returns Integer
The current value.
procedure AutoFlushLimit(NewValue: Integer)
Specifies whether the logger should automatically flush after a certain number of log entries. If you want to disable auto-flushing, set this to 0.
Integer
procedure InitializeFromCaller(Category: Text): Boolean
Initializes the logger from the calling app and the given category. This replaces all currently cached loggers with the configured ones.
Category Text[]
The category.
Returns Boolean
true
if the logger was actually initialized, false
if it already was initialized.
procedure LogMessage(EventId: Text; Message: Text)
Logs a message to all underlying loggers with the specified event id and message.
EventId Text[]
The event id.
Message Text[]
The message.
procedure LogMessage(EventId: Text; Message: Text; Payload: Dictionary of [Text, Text])
Logs a message to all underlying loggers with the specified event id and message. Includes additional properties through the payload.
EventId Text[]
The event id.
Message Text[]
The message.
Payload Dictionary[Text,Text]
The additional properties payload.
procedure LogMessage(EventId: Text; Message: Text; Verbosity: Verbosity; DataClassification: DataClassification; Scope: TelemetryScope)
Logs a message to all underlying loggers with the specified properties.
EventId Text[]
The event id.
Message Text[]
The message.
Verbosity Verbosity
The verbosity.
DataClassification DataClassification
The data classification.
Scope TelemetryScope
The scope.
procedure LogMessage(EventId: Text; Message: Text; Verbosity: Verbosity; DataClassification: DataClassification; Scope: TelemetryScope; Payload: Dictionary of [Text, Text])
Logs a message to all underlying loggers with the specified properties.
EventId Text[]
The event id.
Message Text[]
The message.
Verbosity Verbosity
The verbosity.
DataClassification DataClassification
The data classification.
Scope TelemetryScope
The scope.
Payload Dictionary[Text,Text]
The additional properties payload.
procedure AssertInitialized()
Ensures that this instance has been initialized. If it hasn’t, a runtime error will be thrown.
procedure IsEnabled(): Boolean
Specifies whether there exist any enabled underlying loggers. If this instance has not yet been initialized, this will always return false.
Returns Boolean
true
if there exist any enabled underlying loggers, false
otherwise.
procedure CollectLogCategories(AppId: Guid; var TempLogCategory: Record "EOS004 App Log Category")
Collects all log categories for the specified app. This method can be called even if the instance has not been initialized.
AppId Guid
The app id.
TempLogCategory Record "EOS004 App Log Category"
Will contain all categories for the given app.
procedure Flush(): Integer
Flushes all underlying loggers.
Returns Integer
The total number of log entries that were flushed.
local procedure OnCollectLogCategories(AppId: Guid; var TempLogCategory: Record "EOS004 App Log Category")
Raised when collecting log categories for the specified app. Subscribe to this to provide categories your app can log to. You must provide at least one non-empty category in order for your app to be usable by this logger framework.
AppId Guid
The Id of the app for which categories are requested.
TempLogCategory Record "EOS004 App Log Category"
The record containing the log categories for the app.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.