edit-icon download-icon

iOS SDK

Last Updated: Apr 09, 2018

Alibaba Cloud Log Service SDKs are implemented based on APIs and currently provide the log writing function.

GitHub address:

Swift

  1. /*
  2. Use the endpoint, AccessKey ID, and AccessKey Secret to build the Log Service client.
  3. @endPoint: The service endpoint.
  4. */
  5. let myClient = try! LOGClient(endPoint: "",
  6. accessKeyID: "",
  7. accessKeySecret: "",
  8. projectName:"")
  9. /* Create a log group. */
  10. let logGroup = try! LogGroup(topic: "mTopic",source: "mSource")
  11. /* Store a log. */
  12. let log1 = Log()
  13. try! log1.PutContent("K11", value: "V11")
  14. try! log1.PutContent("K12", value: "V12")
  15. try! log1.PutContent("K13", value: "V13")
  16. logGroup.PutLog(log1)
  17. /* Store a log. */
  18. let log2 = Log()
  19. try! log2.PutContent("K21", value: "V21")
  20. try! log2.PutContent("K22", value: "V22")
  21. try! log2.PutContent("K23", value: "V23")
  22. logGroup.PutLog(log2)
  23. /* Send the log. */
  24. myClient.PostLog(logGroup,logStoreName: ""){ response, error in
  25. // handle response however you want
  26. if error?.domain == NSURLErrorDomain && error?.code == NSURLErrorTimedOut {
  27. print("timed out") // note, `response` is likely `nil` if it timed out
  28. }
  29. }

Objective-C

See GitHub.

Thank you! We've received your feedback.