How can I set the log file?
The Agora SDK provides API methods for you to generate an output log file that records all the log data of the SDK operation.
Native
The native platform includes Android, iOS, macOS, and Windows.
Set the log file
Before v3.3.0
Set the log file path
To ensure that the output log is complete, we recommend calling the setLogFile method to set the log file immediately after you create and initialize RtcEngine.
By default, the SDK outputs five log files, agorasdk.log, agorasdk_1.log, agorasdk_2.log, agorasdk_3.log, agorasdk_4.log, each with a default size of 1024 KB. These log files are encoded in UTF-8. The SDK writes the latest logs in agorasdk.log. When agorasdk.log is full, the SDK deletes the log file with the earliest modification time among the other four, renames agorasdk.log to the name of the deleted log file, and creates a new agorasdk.log to record latest logs.
The default output log file path for each platform is as follows:
- Android:
/storage/emulated/0/Android/data/<package name>/files/agorasdk.log - iOS:
App Sandbox/Library/Caches/agorasdk.log - macOS:
- Sandbox enabled:
App Sandbox/Library/Logs/agorasdk.log, such as/Users/<username>/Library/Containers/<App Bundle Identifier>/Data/Library/Logs/agorasdk.log - Sandbox disabled:
/Users/<username>/Library/Caches/<App Bundle Identifier>/Logs/agorasdk.log
- Sandbox enabled:
- Windows:
C:\Users\<user_name>\AppData\Local\Agora\<process_name>\agorasdk.log
You can change the directory for the log files by setting the filePath parameter when calling setLogFile.
Set the log output level
You can call the setLogFilter method to set the output log level. Select a level, and all the logs in the levels preceding this level are generated.
- DEBUG: Outputs all API logs. Set your log filter as DEBUG if you want to get the most complete log file.
- INFO: Outputs logs of the CRITICAL, ERROR, WARNING, and INFO level. We recommend setting your log filter as this level.
- WARNING: Outputs logs of the CRITICAL, ERROR, and WARNING level.
- ERROR: Outputs logs of the CRITICAL and ERROR level.
- CRITICAL: Outputs logs of the CRITICAL level.
- OFF: Outputs no log.
Set the log file size
The Agora SDK has five log files, each with a default size of 1024 KB. Call the setLogFileSize method if you want to increase the size of each log file.
Sample code
v3.3.0 and later
Use the mLogConfig parameter to set the log file immediately after you create and initialize RtcEngine.
Set the log file path
By default, the SDK outputs five log files, agorasdk.log, agorasdk_1.log, agorasdk_2.log, agorasdk_3.log, agorasdk_4.log, each with a default size of 1024 KB. These log files are encoded in UTF-8. The SDK writes the latest logs in agorasdk.log. When agorasdk.log is full, the SDK deletes the log file with the earliest modification time among the other four, renames agorasdk.log to the name of the deleted log file, and creates a new agorasdk.log to record latest logs.
The default output log file path for each platform is as follows:
- Android:
/storage/emulated/0/Android/data/<package name>/files/agorasdk.log - iOS:
App Sandbox/Library/Caches/agorasdk.log - macOS:
~/Library/Logs/agorasdk.log- Sandbox enabled:
App Sandbox/Library/Logs/agorasdk.log, such as/Users/<username>/Library/Containers/<App Bundle Identifier>/Data/Library/Logs/agorasdk.log - Sandbox disabled:
~/Library/Logs/agorasdk.log
- Sandbox enabled:
- Windows:
C:\Users\<user_name>\AppData\Local\Agora\<process_name>\agorasdk.log
Set the log output level
You can use the level parameter in mLogConfig to set the output log level. Select a level, and all the logs in the levels preceding this level are generated.
- INFO: (Default) Outputs logs of the FATAL, ERROR, WARN, and INFO level. We recommend setting your log filter as this level.
- WARN: Outputs logs of the FATAL, ERROR, and WARN level.
- ERROR: Outputs logs of the FATAL and ERROR level.
- FATAL: Outputs logs of the FATAL level.
- NONE: Do not output any log.
Set the log file size
The Agora SDK has five log files, each with a default size of 1024 KB. Use the fileSize parameter in mLogConfig to set the size of each log file.
Sample code
API reference
- Android
create[2/2]
- iOS/macOS
- Windows
Get the stack information
You can also get the stack information when crashes occur:
- Android: Run the
adb bugreportcommand - iOS:Xcode → window → Devices→ Select the corresponding device → Select the corresponding app → Click the Settings button below the app list → Download Container → Right click the downloaded file and select Show Package Contents → AppData → Library → Caches → agorasdk.log
- macOS:
~/Library/Logs/DiagnosticReports/ - Windows: Need to capture dump files
On Android and iOS, if you have integrated Bugly in your app, you cal also use Bugly to get the stack information.
Web
Enable or disable log upload
You can call enableLogUpload to upload the logs of the Agora Web SDK to the Agora servers, and call disaleLogUpload to stop the upload.
To ensure that the output log is complete, we recommend calling enableLogUpload to upload logs before creating the Client object.
If you fail to join the channel, the logs are unavailable on the Agora servers.
Set the log output level
Call setLogLevel to set the log output level. Select a level, and you can see the logs in the preceding levels.
- DEBUG: Outputs all logs.
- INFO: Outputs logs in the INFO, WARNING and ERROR levels.
- WARNING: Outputs logs in the WARNING and ERROR levels.
- ERROR: Outputs logs in the ERROR level.
- NONE: Outputs no log.
Sample code
See the sample code based on your SDK version.