How do I write messages to the output log on AWS Glue?

后端 未结 5 806
小鲜肉
小鲜肉 2021-02-05 06:00

AWS Glue jobs log output and errors to two different CloudWatch logs, /aws-glue/jobs/error and /aws-glue/jobs/output by default. When I include p

5条回答
  •  长发绾君心
    2021-02-05 06:38

    Try to use built-in python logger from logging module, by default it writes messages to standard output stream.

    import logging
    
    MSG_FORMAT = '%(asctime)s %(levelname)s %(name)s: %(message)s'
    DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
    logging.basicConfig(format=MSG_FORMAT, datefmt=DATETIME_FORMAT)
    logger = logging.getLogger()
    
    logger.setLevel(logging.INFO)
    
    ...
    
    logger.info("Test log message")
    

提交回复
热议问题