All Products
Search
Document Center

Alibaba Cloud SDK:Use the logging feature

Last Updated:Feb 23, 2022

Configure a logger

from aliyunsdkcore.client import AcsClient
from aliyunsdkecs.request.v20140526.AcceptInquiredSystemEventRequest import AcceptInquiredSystemEventRequest

import sys

client = AcsClient(
    '<access_key_id>',
    '<access_secret>',
    '<region_id>"'
)
client.set_stream_logger(
    stream=sys.stderr.# The output object of logs.
    format_string='%(thread)d %(asctime)s %(name)s %(levelname)s %(message)s' # The output format of logs.
)

client.set_file_logger(
    path='<file_path>' # The path of log files.
)