3

On Google AI Platform, all logs printed on stderr are interpreted as ERROR. Is there any way to print logs as INFO, WARNING, and CRITICAL?

enter image description here

Brian Bien
  • 723
  • 8
  • 21
Shuhei Fujiwara
  • 193
  • 1
  • 7

2 Answers2

1

In my case, I was using FastAPI which sends all logs to standard error, leading to the ERROR severity in Cloud Logging. The solution was to add a FastAPI logging config file that instead sends logs to standard out. Then, the Python severity was used as desired.

Brian Bien
  • 723
  • 8
  • 21
0

Take a look at the AI Platform troubleshooting documentation for training logs. There is stated that You can put logging events in your application with standard Python libraries, such like logging.

I haven't tried it but it seems that you can use the logger object class to set the log level desired:

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().
Kim
  • 326
  • 1
  • 5
  • I tried logging module, but the result is the picture above. Though writing `logger.info`, it's interpreted as severity ERROR. – Shuhei Fujiwara Jan 10 '21 at 13:55
  • Take a look at this other [python logging documentation](https://cloud.google.com/logging/docs/setup/python), it may be helpful, however it seems that the logs from AI Platform are captured into stderr and are hence labeled as "ERROR" type. Also, take a look at the [audit logs documentation](https://cloud.google.com/ai-platform/training/docs/audit-logs), this kind of logs are slightly different but they are useful depending on the use case. – Kim Jan 12 '21 at 07:48