aws / sagemaker-inference-toolkit

Serve machine learning models within a 🐳 Docker container using 🧠 Amazon SageMaker.
Apache License 2.0
385 stars 82 forks source link

logging in JSON format #59

Open alext234 opened 4 years ago

alext234 commented 4 years ago

I've started looking at start_model_server() and this documentation on logging at https://github.com/awslabs/multi-model-server/blob/master/docs/logging.md

but still not sure how we go about changing it to output JSON format, with extra custom fields.

Is there any guide on this part?

chuyang-deng commented 4 years ago

Hi @alext234 , the MMS documentation does not seem to mention that model server logs can be converted to JSON format. what is the log contents that you wish to see but we did not output?

Also, if you want to use a different log level, you could use SAGEMAKER_CONTAINER_LOG env var to adjust that.

alext234 commented 4 years ago

Hi @ChuyangDeng JSON format would be convenient for centralised logging system to easily index and search. We can also add custom kv fields to the logs. One use-case is we add a json formatter to the standard Python logging module any log from our code are in JSOn format, for example

            logger.info("inference completed", extra={"result": result})