Skip to content

SimpleLoggerAdvisor should allow JSON formatting #1364

Open
@michaelisvy

Description

@michaelisvy

I am using a SimpleLoggerAdvisor as follows:

public BookRecommendationService(ChatClient.Builder builder) {
        this.chatClient = builder.defaultAdvisors(new SimpleLoggerAdvisor()).build();
 }

It works well, except that the JSON snippets in the logs are heard to read:

2024-09-15T22:16:35.519+08:00 DEBUG 28615 --- [spring-ai-samples2] [           main] o.s.a.c.c.advisor.SimpleLoggerAdvisor    : response: {"result":{"output":{"messageType":"ASSISTANT",
"metadata":{"refusal":"","finishReason":"STOP","index":0,"id":"chatcmpl-A7kLD5Ez8836Wq9a6RKfqh7d3PJYv","role":"ASSISTANT","messageType":"ASSISTANT"},
"toolCalls":[],"content":"{\n  \"author\": \"Bonnie Garmus\",\n  \"title\": \"Lessons in Chemistry\"\n}"},"metadata":
{"contentFilterMetadata":null,"finishReason":"STOP"}},`...

It would be nice if there was a way to format the JSON snippets properly in the logs, so it would be more readable and also would not display the '\n' instructions.

Thanks again for the great work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions