totime = int(time.time())
starttime = totime - 86400
req = GetLogsRequest(project=my_project,logstore=my_logstore,fromTime=starttime,toTime=totime,)
res = client.get_logs(req)
c=res.get_logs()
我试过设置参数 line
和 offset
,但是设置完以后,获得的记录条数就变成零了,这个参数应该怎么设置。
你好,支持的, size传-1会试图拿所有:
https://aliyun-log-python-sdk.readthedocs.io/api.html#aliyun.log.LogClient.get_log
但数据量超大时,过于占用内存,推荐使用get_all_log,迭代方式效率更好;
https://github.com/aliyun/aliyun-log-python-sdk/blob/master/tests/sample.py#L96
API文档:
get_log: https://aliyun-log-python-sdk.readthedocs.io/api.html#aliyun.log.LogClient.get_log
get_all_log: https://aliyun-log-python-sdk.readthedocs.io/api.html#aliyun.log.LogClient.get_log_all