How can I obtain the SDK logs and stack traces?
Products / Plugins:Video Call / Voice Call / Live Streaming
Platform / Framework:iOS / Android / macOS / Windows / Web
Last updated:2022-03-25 15:51
Native
Native refers to the Android, iOS, macOS, and Windows platforms.
Set SDK log property
By default, the SDK generates the TXT log files with the prefix zegoavlog
. And up to three files can be generated, the file names end with sequence numbers 1, 2, and 3.
By default, the maximum size of a log file is 5MB (5 x 1024 x 1024 Bytes). When the three log files are all in full condition, the SDK deletes the earliest log file.
The following are the default log storage path for different platforms:
- Android: /storage/Android/data/[application package name]/files
- iOS: ~/Library/Caches/ZegoLogs
- macOS:
- Sandbox: ~/Library/Containers/[application package name Bundle ID]/Data/Library/Caches/ZegoLogs
- Non-sandbox: ~/Library/Caches/ZegoLogs
- Windows: C:\User\Current username\AppData[application package name]ZEGO.SDK\ZegoLogs
To set the SDK log property (ZegoLogConfig
), refer to the following:
- Set the log storage path:
logPath
- Set the log file size:
logSize
- Customize the SDK log property: call the
setLogConfig
method
To ensure the integrity of the SDK logs, we recommend you call the setLogConfig
method to set the SDK log property right after creating the ZegoExpressEngine.
Android
The following is the sample code that sets the log path to /data/user/0/package name/files
, and max file size to 5MB:
ZegoLogConfig logConfig;
// Set the log storage path.
logConfig.logPath = getApplicationContext().getFilesDir().getAbsolutePath();
// Set the max file size for a log file.
logConfig.logSize = 5242880L;
engine.setLogConfig(logConfig);
API reference: ZegoLogConfig
, setLogConfig
iOS/macOS
The following is the sample code that sets the log path to [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingString:@"/ZegoLogs"]
, and max file size to 5MB:
// Set the log storage path.
NSString *appLogPath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingString:@"/ZegoLogs"];
ZegoLogConfig *logConfig = [[ZegoLogConfig alloc] init];
logConfig.logPath = appLogPath;
// Set the max file size for a log file.
logConfig.logSize = 5 * 1024 * 1024;
[ZegoExpressEngine setLogConfig:logConfig];
API reference:
- iOS:
ZegoLogConfig
、setLogConfig - macOS:
ZegoLogConfig
、setLogConfig
Windows
The following is the sample code that sets the log path to /Users/zego/Log/log.txt
, and max file size to 5MB:
ZegoLogConfig logConfig;
// Set the log storage path.
logConfig.logPath = "/Users/zego/Log/log.txt";
// Set the max file size for a log file.
logConfig.logSize = 5242880L;
ZegoExpressSDK::setLogConfig(logConfig);
API reference: ZegoLogConfig
、setLogConfig
Obtain the SDK logs
Follow these procedures to obtain the SDK logs for different platforms.
The following procedures use the default SDK path, you will need to use the correct path if you customized the directory path for SDK logs.
Android
Go to /storage/Android/data/[application package name]/files, and the TXT files that start with the prefix
zegoavlog
are the log files.iOS/iPadOS
Connect your iOS device to your Mac.
Open Xcode, and then select Window > Devices and Simulators on the menu bar.
Select your device on the left pane. Under INSTALLED APPS, select the app that you want to get the logs for. From the Action menu (the gear icon) below the table, choose Download Container. In the sheet that appears, enter a location and click Save. The saved file will have a
.xcappdata
filename extension.Open the Finder to find the
.xcappdata
file saved in the previous step. Right-click the file and select Show Package Contents, and then go to AppData > Library > Caches > ZegoLogs. The TXT files that start with the prefixzegoavlog
are the log files.
macOS
- Sandbox: Go to ~/Library/Containers/[application package name Bundle ID]/Data/Library/Caches/ZefLogs. The TXT files that start with the prefix
zegoavlog
are the log files.
- Sandbox: Go to ~/Library/Containers/[application package name Bundle ID]/Data/Library/Caches/ZefLogs. The TXT files that start with the prefix
- Non-sandbox: Go to **~/Library/Caches/ZefLogs**. The TXT files that start with the prefix `zegoavlog` are the log files.
Windows
Open the File Explorer, type %APPDATA% into the address bar, and press Enter. It will take you directly to the folder where the log file folder is located. The name of the log file folder is Process name of the program + ZEGO.SDK, and the TXT files that start with the prefix
zegoavlog
are the log files.
Obtain the SDK stack traces
Follow these procedures to obtain the SDK stack traces for different platforms.
Android
Analyze logs in real time
adb logcat | ndk-stack -sym $PROJECT_DYNAMIC_LIB_PATH
Note:
$PROJECT_DYNAMIC_LIB_PATH
is the path to the dynamic library directory (where the.so
files are located) of the target ABI (armeabi
,armeabi-v7a
, orarm64-v8a
).
For example:
adb logcat | ndk-stack -sym /path/to/your/project/armeabi-v7a
Analyze the log files after obtaining them
Use
adb logca
to save the log files, and then analyze them by usingndk-stack
.adb logcat> xx.log
ndk-stack -sym $PROJECT_DYNAMIC_LIB_PATH -dump $LOG_FILE
Note:
$PROJECT_DYNAMIC_LIB_PATH
is the path to the dynamic library directory (where the.so
files are located) of the target ABI (armeabi
,armeabi-v7a
, orarm64-v8a
).$LOG_FILE
is the name of the output log file.
For example:
adb logcat> crash.log
ndk-stack -sym /path/to/your/project/armeabi-v7a -dump crash.log
iOS/iPadOS
Connect your iOS device to the Mac.
Open Xcode, and select Window > Devices and Simulators on the menu bar.
Select your device on the left pane, click View Device Logs.
Select the log entries that meet the following criteria:
a. Process is your application name.
b. Type is crash.
c. Date/Time is in the time period when the crash happened.
Right-click the log entry and select Export Log, and save the log details as a
.crash
file as prompted.
macOS
Go to ~/Library/Logs/DiagnosticReports, and the stack traces are in the files that end with the suffix
.crash
.
Web
The log reporting feature is enabled on the Web by default.
We recommend you use the default log configurations, refer to the following to set the log level when needed.
Set the log level
You can call the setLogConfig
method to set the ZegoLogConfig
property to set related log properties, such as, the Web console log level logLevel
, the reported log level remoteLogLevel
and the reported log address logURL
.
The logLevel
and remoteLogLevel
property can be set as follows:
Property | Log level | |
---|---|---|
logLevel |
Level of Web console logs |
|
remoteLogLevel |
Level of reporting logs |
|
You can set the logURL
property to your report the logs to your own address based on the actual situations, pass a null string will report the logs to ZEGO.
The following is the sample code that sets the level of Web console logs and reported logs to debug
, and sets the address of the reported logs to ZEGO
:
const config = {
logLevel: 'debug',
remoteLogLevel: 'debug',
logURL: ''
};
zg.setLogConfig(config);