【问题标题】:Severities of all logs on AI Platform are errorsAI Platform 上所有日志的严重性为错误
【发布时间】:2021-04-01 16:52:23
【问题描述】:

在 Google AI Platform 上,打印在 stderr 上的所有日志都被解释为 ERROR。 有没有办法将日志打印为 INFO、WARNING 和 CRITICAL?

【问题讨论】:

    标签: google-cloud-ml google-cloud-logging gcp-ai-platform-training google-ai-platform


    【解决方案1】:

    查看training logs 的 AI Platform 故障排除文档。有说You can put logging events in your application with standard Python libraries,比如logging。

    我没有尝试过,但似乎可以使用记录器对象类来设置所需的日志级别:

    Logger.info(msg, *args, **kwargs)
    Logs a message with level INFO on this logger. The arguments are interpreted as for debug().
    
    Logger.warning(msg, *args, **kwargs)
    Logs a message with level WARNING on this logger. The arguments are interpreted as for debug().
    
    Logger.critical(msg, *args, **kwargs)
    Logs a message with level CRITICAL on this logger. The arguments are interpreted as for debug().
    

    【讨论】:

    • 我试过日志模块,结果就是上图。虽然写了logger.info,但它被解释为严重错误。
    • 看看另一个python logging documentation,它可能会有所帮助,但似乎来自 AI Platform 的日志被捕获到 stderr 中,因此被标记为“错误”类型。另外,看看audit logs documentation,这种日志略有不同,但根据用例而定。
    猜你喜欢
    • 2020-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-10
    • 1970-01-01
    • 1970-01-01
    • 2012-06-06
    相关资源
    最近更新 更多