Log Analysis
Enabling System Logging
Sample code:
static OBSClient *client;
NSString *endPoint = @"your-endpoint";
NSString *SK = @"*** Provide your Secret Key ***";
NSString *AK = @"*** Provide your Access Key ***";
// Initialize identity authentication.
OBSStaticCredentialProvider *credentialProvider = [[OBSStaticCredentialProvider alloc] initWithAccessKey:AK secretKey:SK];
//Initialize service configuration.
OBSServiceConfiguration *conf = [[OBSServiceConfiguration alloc] initWithURLString:endPoint credentialProvider:credentialProvider];
// Initialize an instance of OBSClient.
client = [[OBSClient alloc] initWithConfiguration:conf];
// *****Logging settings*******
// Specify that system logs will be printed.
[client addLogger:[OBSDDASLLogger sharedInstance]];
// Specify that the logs will be displayed in the window.
[client addLogger:[OBSDDTTYLogger sharedInstance]];
// Set log files.
OBSDDFileLogger *fileLogger = [[OBSDDFileLogger alloc] init];
// Set the log retention duration.
fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling
// Set the maximum number of log files that can be retained.
fileLogger.logFileManager.maximumNumberOfLogFiles = 7;
// Customize log settings.
[client addLogger:fileLogger];
// Set the path for saving log files.
OBSDDLogFileInfo *ts =[fileLogger currentLogFileInfo];
NSLog(@"%@", ts);
// Set the log level.
[client setLogLevel:OBSDDLogLevelDebug];
// Enable logging.
[client setASLogOn]; Log Level
When current logs cannot be used to troubleshoot system faults, you can change the log level to obtain more information. You can obtain the most information in OBSDDLogLevelVerbose logs and the least information in OBSDDLogLevelError logs. The default value is OBSDDLogLevelInfo.
| Log Level | Description |
|---|---|
| OBSDDLogLevelOff | Disables logging. |
| OBSDDLogLevelError | Prints error information only. |
| OBSDDLogLevelWarning | Prints error and alarm information. |
| OBSDDLogLevelInfo | Prints error, warning, and basic running information. |
| OBSDDLogLevelDebug | Prints error, warning, basic running, and debugging information. |
| OBSDDLogLevelVerbose | Prints all logs. |
Last Article: SDK Common Response Headers
Next Article: FAQ
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.