This repository demonstrates three beginner-friendly approaches to log requests and responses when using Spring AI.
We want to log both the requests and the responses when making use of Spring AI in a Spring Boot application.
We found three effective approaches to make this happen—thanks to:
We’ve written a detailed blog that explains each logging method with code snippets, setup instructions, and FAQs to help you get started:
🔗 Blog: Spring AI Log Model Requests and Responses - 3 Easy Ways
Approach | Description | Branch |
---|---|---|
✅ Custom Interceptor | Uses RestClientCustomizer and a custom interceptor to log request/response details. |
main |
📒 Logbook Integration | Leverages Zalando’s Logbook to log HTTP traffic cleanly. | logbook-logging |
🧩 SimpleLoggerAdvisor | Uses Spring AI’s built-in SimpleLoggerAdvisor for logging. |
simple-logger-advisor-logging |
✨ Choose the branch based on the implementation you'd like to explore.