Skip to main content
Version: 5.21.0

Logger

The SDK logs events to a file. By default it is disabled — ChatCenterUI is created without ChatLoggerConfig, and no logs are written to the file or console. If a config is passed but logLevel is not set explicitly, VERBOSE is used (see the table below).

Log levels (ChatLogLevel)​

LevelDescription
VERBOSEMaximum-detail logs, for development only
DEBUGDetailed logs for debugging
INFOMain SDK events
WARNINGWarnings and non-standard situations
ERROROnly critical errors (recommended for production)
ChatLogLevel.FLUSH

The ChatLogLevel enum has a FLUSH value — this is an internal SDK trigger to flush the log buffer to the file. Do not pass it to ChatLoggerConfig.logLevel: the SDK filter will drop all records and logging will effectively be disabled. To force a flush, use LoggerEdna.flushLogs().

ChatLoggerConfig​

val loggerConfig = ChatLoggerConfig(
applicationContext = applicationContext,
logLevel = ChatLogLevel.VERBOSE,
logFileSize = 1,
logFileMaxCount = 5,
shouldShowSendMenu = true
)

chatCenterUI = ChatCenterUI(applicationContext, loggerConfig)

The parameter order in the table matches the constructor order of ChatLoggerConfig (package edna.chatcenter.core.logger).

#ParameterTypeRequiredDefaultDescription
1applicationContextContextYes—Must be applicationContext (otherwise the init block throws IllegalArgumentException)
2logLevelChatLogLevelNoVERBOSELog level (see the table above; do not use FLUSH)
3logFileSizeIntNo1Maximum log file size, MB
4logFileMaxCountIntNo5Maximum number of log files (rotation)
5logInterceptorChatLoggerConfig.LogInterceptor? (var)NonullCustom interceptor. The field is mutable — it can be set after the config is created: loggerConfig.logInterceptor = .... See below
6shouldShowSendMenuBooleanNotrueShow the log-send menu when the device is shaken
Production builds
  • logLevel = ChatLogLevel.ERROR or WARNING. The SDK logs ChatUser.identifier at the INFO level — at INFO or below, the identifier ends up in device logs, which violates personal-data requirements when a real ID is used.
  • shouldShowSendMenu = false. The "send logs" menu via the shake gesture is convenient for developers but is not acceptable for end users.

Custom log interceptor (LogInterceptor)​

To send SDK logs to Crashlytics, Sentry, or another tool, implement the nested ChatLoggerConfig.LogInterceptor interface:

val loggerConfig = ChatLoggerConfig(
applicationContext = applicationContext,
logLevel = ChatLogLevel.DEBUG,
logInterceptor = object : ChatLoggerConfig.LogInterceptor {
override fun addLogEvent(logLevel: ChatLogLevel, logText: String) {
// For example, send to Crashlytics
FirebaseCrashlytics.getInstance().log("[$logLevel] $logText")
}
}
)
Full path — ChatLoggerConfig.LogInterceptor

This is a nested interface inside ChatLoggerConfig, not top-level. Import: import edna.chatcenter.core.logger.ChatLoggerConfig.LogInterceptor.

logLevel filtering is applied before the interceptor

The SDK first drops records below config.logLevel, and only then calls LogInterceptor.addLogEvent(...). If logLevel = ChatLogLevel.ERROR in the config, the interceptor will not receive VERBOSE/DEBUG/INFO/WARNING events. If you want all events to go to Crashlytics/Sentry, leave logLevel = VERBOSE and filter inside addLogEvent yourself.

Forced log flush (LoggerEdna.flushLogs())​

If you need to guarantee that the log buffer is written to the file (for example, before sending a crash report), call the static method:

LoggerEdna.flushLogs()

Import: import edna.chatcenter.core.logger.LoggerEdna.

The logger must be initialized

LoggerEdna.flushLogs() works only after the SDK has been initialized (chatCenterUI.init(providerUid, appMarker, config) — specifically init, not the ChatCenterUI constructor). Before init(...) completes, calling flushLogs() silently does nothing.

Log collection via shake​

With shouldShowSendMenu = true (the default), the user can export logs right from the app: open the chat screen, shake the device — the "send logs" menu appears with a choice of sending method (mail, messenger, etc.). The scenario is intended for debug builds and QA — in production, disable shake via shouldShowSendMenu = false.

Shake result: log-send menu

Log-send menu

On the emulator​

The emulator does not respond to a physical shake; use the command:

adb emu sensor set acceleration 50:50:50; sleep 0.1; adb emu sensor set acceleration 0:0:0

Sometimes the emulator creates several archives in a row — send any one of them, ignore the rest.

Direct access via Device Explorer​

Connect the device to Android Studio, open View → Tool Windows → Device Explorer, navigate to data/data/<package>/files/logs/, and copy the files.

Location of the "Device Explorer" tab

Location of the &quot;Device Explorer&quot; tab

"data/data" and "logs" folders

The &quot;data/data&quot; folder

The &quot;logs&quot; folder

  • Advanced settings — release preparation recommendations, including ChatLogLevel.ERROR in production.
  • SDK initialization — ChatLoggerConfig is passed to the ChatCenterUI constructor.
  • A logger setup example in the demo app.