BerriAI / litellm

Call all LLM APIs using the OpenAI format. Use Bedrock, Azure, OpenAI, Cohere, Anthropic, Ollama, Sagemaker, HuggingFace, Replicate (100+ LLMs)
https://docs.litellm.ai/docs/
Other
10.05k stars 1.12k forks source link

[Feature]: Include timestamp and log level in JSON logging #4248

Closed jeromeroussin closed 1 week ago

jeromeroussin commented 1 week ago

The Feature

JSON logging allows for easier machine-reading of logs, and automated alerting, but Litellm currently strips away everything but the message during the JSON formatter:

class JsonFormatter(Formatter):
    def __init__(self):
        super(JsonFormatter, self).__init__()

    def format(self, record):
        json_record = {}
        json_record["message"] = record.getMessage()
        return json.dumps(json_record)

Motivation, pitch

Make JSON logging more useful for automated monitoring of litellm proxy

Twitter / LinkedIn details

https://www.linkedin.com/in/jeromeroussin/