sagemaker-inference-toolkit icon indicating copy to clipboard operation
sagemaker-inference-toolkit copied to clipboard

logging in JSON format

Open alext234 opened this issue 3 years ago • 2 comments

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?

alext234 avatar Jul 17 '20 05:07 alext234

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.

chuyang-deng avatar Jul 21 '20 04:07 chuyang-deng

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})

alext234 avatar Jul 30 '20 23:07 alext234