spring-projects/spring-ai · warning

You have enabled logging out the ChatClient completion…

Error message

You have enabled logging out the ChatClient completion content with the risk of exposing sensitive or private information. Please, be careful!

What it means

ChatClientAutoConfiguration.logCompletionWarning emits this warning when completion (LLM response) content logging is enabled for the ChatClient. Because logged completions can contain user-derived sensitive data, the library warns at auto-configuration time whenever you opt in.

Solutions

  1. Turn the property off in production (log-completion-content=false).
  2. Enable it only under dev/test profiles.
  3. Use sampling/truncation or a log redaction layer if completions must be retained.

Example fix

// before (application.yml)
spring.ai.chat.client.observation.log-completion-content: true
// after
spring.ai.chat.client.observation.log-completion-content: false
Defensive patterns

Strategy: validation

Validate before calling

boolean loggingCompletions = env.getProperty(
    "spring.ai.chat.client.observation.log-completion-content", Boolean.class, false);
if (loggingCompletions && isProduction) {
    throw new IllegalStateException("Completion content logging must be disabled in production");
}

Prevention

When it happens

Trigger: Setting the ChatClient completion-content logging property (e.g. spring.ai.chat.client.observation.log-completion-content=true) so the conditional logCompletionWarning bean method executes.

Common situations: Debugging model outputs locally and forgetting to revert; shared config enabling both prompt and completion logging; production log aggregation then capturing end-user data, breaching privacy policies.

Related errors


AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11). Data as JSON: /api/errors/4e2f38387055bdb8. Report an issue: GitHub.

Appendix: source

Thrown at auto-configurations/models/chat/client/spring-ai-autoconfigure-model-chat-client/src/main/java/org/springframework/ai/model/chat/client/autoconfigure/ChatClientAutoConfiguration.java:82

 * @author Jonatan Ivanov
 * @since 1.0.0
 */
@AutoConfiguration(after = ToolCallingAutoConfiguration.class)
@ConditionalOnClass(ChatClient.class)
@EnableConfigurationProperties(ChatClientBuilderProperties.class)
@ConditionalOnProperty(prefix = ChatClientBuilderProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true",
		matchIfMissing = true)
public class ChatClientAutoConfiguration {

	private static final Log logger = LogFactory.getLog(ChatClientAutoConfiguration.class);

	private static void logPromptContentWarning() {
		logger.warn(
				"You have enabled logging out the ChatClient 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 ChatClient completion content with the risk of exposing sensitive or private information. Please, be careful!");
	}

	@Bean
	@ConditionalOnMissingBean
	@SuppressWarnings("removal")
	ChatClientBuilderConfigurer chatClientBuilderConfigurer(ObjectProvider<ChatClientCustomizer> customizerProvider,
			ObjectProvider<ChatClientBuilderCustomizer> builderCustomizerProvider) {
		ChatClientBuilderConfigurer configurer = new ChatClientBuilderConfigurer();
		configurer.setChatClientCustomizers(customizerProvider.orderedStream().toList());
		configurer.setChatClientBuilderCustomizers(builderCustomizerProvider.orderedStream().toList());
		return configurer;
	}

	@Bean
	@ConditionalOnMissingBean
	@ConditionalOnBean(ToolCallingManager.class)
	ToolCallingAdvisor.Builder<?> toolCallingAdvisorBuilder(ChatClientBuilderProperties properties,

View on GitHub (pinned to 98a7beda4f)