spring-projects/spring-ai · warning
You have enabled logging out the prompt content with the…
Error message
You have enabled logging out the prompt content with the risk of exposing sensitive or private information. Please, be careful!
What it means
ChatObservationAutoConfiguration.logPromptContentWarning emits this warning when chat model observation logging of prompt content is enabled. Prompt text may contain sensitive user data, so the library warns whenever the property opts you into logging it in observations.
Solutions
- Set spring.ai.chat.observation.log-prompt-content=false in production.
- Scope the property to dev/test profiles only.
- If tracing needs content, use a telemetry backend with redaction and restricted access.
Example fix
// before (application.yml) spring.ai.chat.observation.log-prompt-content: true // after spring.ai.chat.observation.log-prompt-content: false
Defensive patterns
Strategy: validation
Validate before calling
boolean loggingPrompts = env.getProperty(
"spring.ai.chat.observation.log-prompt-content", Boolean.class, false);
if (loggingPrompts && isProduction) {
throw new IllegalStateException("Prompt content observation logging must be off in production");
} Prevention
- Default log-prompt-content to false in shared config.
- Gate content logging behind dev/test profiles.
- Use a redacting telemetry processor if content tracing is mandatory.
When it happens
Trigger: Setting spring.ai.chat.observation.log-prompt-content=true (via ChatObservationProperties) so the conditional logPromptContentWarning bean method runs during auto-configuration.
Common situations: Turning on observation content logging for tracing in dev and promoting the config to production; compliance requirements (GDPR/PII) violated by prompt traces in log backends; copying sample tracing configs.
Related errors
- You have enabled logging out the ChatClient completion…
- You have enabled logging out the ChatClient prompt content…
- You have enabled logging out the image prompt content with…
- You have enabled the inclusion of the tool call arguments…
- Bean must not be null
AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11).
Data as JSON: /api/errors/4b28b731106ddb46.
Report an issue: GitHub.
Appendix: source
Thrown at auto-configurations/models/chat/observation/spring-ai-autoconfigure-model-chat-observation/src/main/java/org/springframework/ai/model/chat/observation/autoconfigure/ChatObservationAutoConfiguration.java:66
/**
* Auto-configuration for Spring AI chat model observations.
*
* @author Thomas Vitale
* @author Jonatan Ivanov
* @since 1.0.0
*/
// afterName: CompositeMeterRegistryAutoConfiguration declares a MeterRegistry bean that
// some beans here are conditional on
@AutoConfiguration(
afterName = "org.springframework.boot.micrometer.metrics.autoconfigure.CompositeMeterRegistryAutoConfiguration")
@ConditionalOnClass(ChatModel.class)
@EnableConfigurationProperties(ChatObservationProperties.class)
public class ChatObservationAutoConfiguration {
private static final Log logger = LogFactory.getLog(ChatObservationAutoConfiguration.class);
private static void logPromptContentWarning() {
logger.warn(
"You have enabled logging out the prompt content with the risk of exposing sensitive or private information. Please, be careful!");
}
private static void logCompletionWarning() {
logger.warn(
"You have enabled logging out the completion content with the risk of exposing sensitive or private information. Please, be careful!");
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(MeterRegistry.class)
ChatModelMeterObservationHandler chatModelMeterObservationHandler(ObjectProvider<MeterRegistry> meterRegistry) {
return new ChatModelMeterObservationHandler(meterRegistry.getObject());
}
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(Tracer.class)
@ConditionalOnBean(Tracer.class)View on GitHub (pinned to 98a7beda4f)