Spring-boot, logback, and spring-cloud-bus-kafka

I’m encountering weird behavior I can’t seem to resolve. I’m using sentry-spring-boot-starter and sentry-logback in my application. The sentry properties are obtained from a Spring Cloud service. The exception sentry events from sentry-spring-boot-starter and the logger sentry events from sentry-logback both work, but once I add spring-cloud-starter-bus-kafka as a dependency, the sentry-logback integration no longer works - just the sentry-spring-boot-starter integration. Placing local application.yml, application.properties, bootstrap.properties don’t help. How can I use sentry-logback integration with spring-cloud-starter-bus-kafka?

Could you please share a repro? Like a GitHub repository with a small app we can run and see the behavior?

Sure, take a look at https://github.com/ninjagumby/sentry-spring-cloud-bus-kafka/.

Did that reproduce the issue for you?

Thanks @ninjagumby for reporting. It is indeed an issue we will fix in the next release. As a temporary workaround adding this component should fix it for you:

import io.sentry.spring.boot.SentryLogbackAppenderAutoConfiguration;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.GenericApplicationListener;
import org.springframework.core.ResolvableType;
import org.springframework.stereotype.Component;

@Component
public class SentryLogbackEventListener implements GenericApplicationListener {
	private final SentryLogbackAppenderAutoConfiguration sentryLogbackAppenderAutoConfiguration;

	SentryLogbackEventListener(SentryLogbackAppenderAutoConfiguration sentryLogbackAppenderAutoConfiguration) {
		this.sentryLogbackAppenderAutoConfiguration = sentryLogbackAppenderAutoConfiguration;
	}

	@Override
	public boolean supportsEventType(ResolvableType eventType) {
		return ContextRefreshedEvent.class.isAssignableFrom(eventType.getRawClass());
	}

	@Override
	public void onApplicationEvent(ApplicationEvent event) {
		sentryLogbackAppenderAutoConfiguration.afterPropertiesSet();
	}
}
1 Like