Hello! I am trying to configure logging that will ...
# ask-community
d
Hello! I am trying to configure logging that will be integrated with AWS Cloudwatch. I currently have standard logging but I am trying to figure out how to set up the logging so that only ERROR and CRITICAL logs get passed to AWS Cloudwatch. I still need the standard logging but do not want Cloudwatch to include all logs. I know i can add extra loggers but I am confused how to set up both standard and error/critical logging together
z
Hi @Daniel Black -- you can set the log level on individual handlers. For example:
Copy code
def get_logger():
    logger = prefect.context.get("logger")
    handler = CloudWatchHandler(...)
    handler.setLevel(logging.ERROR)
    logger.addHandler(handler)
    return logger


@task()
def report_start_day():
    logger = get_logger()
    <http://logger.info|logger.info>(prefect.context.today)