Say I have the following bean definition:
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="maxActive" value="50"/>
<property name="maxIdle" value="5"/>
Is there a way to get Spring to log all of the properties that it has set (without enabling verbose logging for Spring in log4j). I was thinking of something along the lines of... verbose="true"
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource" verbose="true">
Update
I used the following, as suggested in the answer:
public class SpringBeanLoggingPostProcessor implements BeanPostProcessor {
private static final Logger log = Logger.getLogger(SpringBeanLoggingPostProcessor.class);
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean.getClass() == org.apache.commons.dbcp.BasicDataSource.class) {
BasicDataSource ds = (BasicDataSource) bean;
log.info("url="+ds.getUrl());
log.info("username="+ds.getUsername());
}
return bean;
}
@Override
public Object postProcessBeforeInitialization(Object bean, String arg1) throws BeansException {
return bean;
}
}