logo
Video Call
On this page

Debugging and Configuration

2023-11-20

Feature Overview

Developers may encounter some errors when integrating the SDK. The SDK will output relevant error logs. Developers can configure the log output path and the size of individual log files as needed.

In addition, the SDK supports calling interfaces to view the current version.

Example Source Code Download

Please refer to Download Example Source Code to get the source code.

For related source code, please check the files in the "/ZegoExpressExample/DebugAndConfig/src/main/java/im/zego/debugandconfig" directory.

Prerequisites

Before using log-related features, please ensure:

Usage Steps

Set log properties

Before creating the engine, you can set log properties by calling the setLogConfig interface.

Taking setting the log storage path to "/data/user/0/package name/files" and the maximum size of a single log file to 5 MB as an example:

ZegoLogConfig logConfig;
// Set log storage path
logConfig.logPath = getApplicationContext().getFilesDir().getAbsolutePath();
// Set maximum size of single log file
logConfig.logSize = 5242880L;
ZegoExpressEngine.setLogConfig(logConfig);

Where ZegoLogConfig contains log-related settings (save path and maximum file size), specifically defined as follows:

public class ZegoLogConfig {
    // Log file save path
    public String logPath = "";
    // Maximum size of log file (Bytes), default is 5 MB (5 * 1024 * 1024 Bytes)
    public long logSize = 5242880L;
}

Create engine

Define the SDK engine object, call the createEngine interface, pass the applied AppID and AppSign to the parameters "appID" and "appSign", and create the engine singleton object.

If you need to register a callback handler, you can pass an object that implements IZegoEventHandler to the parameter "eventHandler". If you do not need to register a callback handler, you can pass "null" to the parameter "eventHandler". If you still need to register a callback after creating the engine, you can set the callback handler by calling the setEventHandler interface.

// Define SDK engine object
ZegoExpressEngine engine;

ZegoEngineProfile profile = new ZegoEngineProfile();
// Please obtain through official website registration, format is 123456789L
profile.appID = appID;
// 64 characters, please obtain through official website registration, format is "0123456789012345678901234567890123456789012345678901234567890123"
profile.appSign = appSign;
// General scenario access
profile.scenario = ZegoScenario.DEFAULT;
// Set application object of the app
profile.application = getApplication();
// Create engine
engine = ZegoExpressEngine.createEngine(profile, null);

(Optional) Enable debug assistant

It is recommended to call the enableDebugAssistant interface during development and debugging to enable the SDK's debug assistant function. When subsequently calling other SDK interfaces, it can not only output logs to the console, but also pop up a reminder when interface calls fail, making it convenient for developers to discover problems and correct them in time.

Warning

When development is completed and before the App is about to go online, please be sure to disable this feature to avoid UI pop-ups when potential errors occur in the online environment.

engine.enableDebugAssistant(true);

Get SDK version number

Call the getVersion interface to get the SDK version number. Developers can use the SDK version number information as the version information of the Engine used by the App, so as to count the SDK versions corresponding to each version of the App online.

Notes

During SDK operation, when developers find that the situation does not meet expectations, they can submit the problem and relevant logs to ZEGOCLOUD Technical Support for locating. ZEGOCLOUD Technical Support may need the Engine version information to assist in locating the problem.

engine.getVersion();

How to set and get SDK logs and stack information?

Previous

Integration with AI Beauty Effects

Next

Usage Restrictions

On this page

Back to top