How Can I Write Logs Directly to AWS S3 from Memory Without First Writing to stdout? (Python, boto3)
问题 I'm trying to write Python log files directly to S3 without first saving them to stdout. I want the log files to be written to S3 automatically when the program is done running. I'd like to use the boto3 put_object method: import atexit import logging import boto3 def write_logs(body, bucket, key): s3 = boto3.client("s3") s3.put_object(Body=body, Bucket=bucket, Key=key) log = logging.getLogger("some_log_name") log.info("Hello S3") atexit.register(write_logs, body=log, bucket="bucket_name",