Logs written to the local files on a client are synchronized to the log server in the following ways:
- Automatic upload: Logs are automatically uploaded to the log server when certain conditions are met.
- Upload based on the switch: Logs are uploaded to the log server based on the switch value delivered by the server.
- Manual upload: Logs are uploaded to the log server when the log upload API is called.
The conditions for automatic log upload are as follows:
- The App triggers the logic for checking log upload upon each cold startup.
- Logs are immediately uploaded when the App is switched to the backend.
- Logs of the same type are uploaded when the number of these logs reaches 40.
- To ensure timely upload of crash logs, a crash log is uploaded each time the App is restarted after a crash.
You can log in to the mPaaS console, choose Mobile Analysis Service > Log management > Configure upload switch, and modify the parameters to dynamically modify the log upload conditions.
Set the URL of the upload switch configuration.
Dynamically control the log upload through the mPaaS console.
The meanings of the parameters are as follows:
- Upload: The settings are effective only when this switch is turned on.
- Network: Select All networks or Only Wi-Fi. This parameter specifies the network through which logs are uploaded.
- Business code: The value is the same as the business code (bizType) set when tracking is created. For more information about common business codes, see View local logs.
- Minimum upload level: Each log has a level when being generated. Logs of a level smaller than or equal to the value specified here are uploaded. For example, if this parameter is set to 2, logs of levels 1 and 2 are uploaded, but logs of level 3 are not uploaded.
- Upload quantity: Specify the number of logs. Logs of current type are uploaded when the specified threshold is reached. For example, you can change the default value 40 to another value.
- Log upload rate: Specify the percentage of users whose logs are uploaded, in per-mil. The value 1000 indicates that logs of all the users are uploaded.
For more information, see Configure the log switch.
If some logs need to be uploaded in real time, call the following API to upload logs manually: