function collectionLog() { var str = ""; $.get(‘/api/rds/DescribeErrorLogs.json?DBInstanceId=rdsa4rpdz4cyig0qteo0g&EndTime=2016-08-14T16:00Z&PageNumber=1&StartTime=2016-08-13T16:00Z&__preventCache=1471255093654‘, function(data) { var count = Math.ceil(data.data.TotalRecordCount/data.data.PageRecordCount); for (var i = count ; i > 0; i--) { var url = ‘/api/rds/DescribeErrorLogs.json?DBInstanceId=rdsa4rpdz4cyig0qteo0g&EndTime=2016-08-14T16:00Z&PageNumber=‘ + i + ‘&StartTime=2016-08-13T16:00Z&__preventCache=1471255093654‘; $.ajax({ url: url, method: ‘GET‘, async: false, success: function(data) { if (data && data.code == 200) { var items = data.data.Items.ErrorLog; // CreateTime ErrorInfo for (var j = 0; j < items.length; j++) { var item = items[j]; str += new Date(item.CreateTime) + ‘ ‘ + item.ErrorInfo + ‘\n‘; } } } }) } console.log(str); }); }
阿里云的错误日志是一条对应一行,这样看起来太痛苦,只能自己通过ajax去获取拼接
时间: 2024-10-11 23:45:49