If your logs are stored in a logstore of Log Service (SLS), you can use the SLS API to query and download them.