(As requested, moved from the issue at Spring Boot: https://github.com/spring-projects/spring-boot/issues/17343 At the moment, when there is an issue during bean creation (exceptions that something is missing or that there are circular dependencies, etc.), the EXCEPTION_MSG contains the trace through all the beans that were involved in the error.
The problem is that this trace is displayed on a single line. Considering that this trace can go through multiple beans (the current one I am trying to fix goes 8 levels deep) this line can get thousands of characters long.
It would be nice if the bean exception trace would be displayed on multiple lines, for readability and to prevent the need of horizontal scrolling, like:
yyyy-mm-dd hh:ii:ss,fff - ERROR: MESSAGE=[Application run failed] TID=[main] CLASS=[org.springframework.boot.SpringApplication] EXCEPTION=[org.springframework.beans.factory.UnsatisfiedDependencyException] EXCEPTION_MSG=[
Error creating bean with name 'someBean':
Unsatisfied dependency expressed through field 'someOtherBean';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'someOtherBean' defined in class path resource [path/to/ResourceAutoConfiguration.class]:
Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [path.to.resource.SomeOtherBean]:
Circular reference involving containing bean 'someBean' - consider declaring the factory method as static for independence from its containing instance.
Factory method 'someOtherBean' threw exception;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'aThirdBean':
Requested bean is currently in creation: Is there an unresolvable circular reference?
] ROOT_CAUSE=[org.springframework.beans.factory.BeanCurrentlyInCreationException] ROOT_CAUSE_MSG=[Error creating bean with name 'aThirdBean': Requested bean is currently in creation: Is there an unresolvable circular reference?] STACKTRACE=[org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
In stead of:
yyyy-mm-dd hh:ii:ss,fff - ERROR: MESSAGE=[Application run failed] TID=[main] CLASS=[org.springframework.boot.SpringApplication] EXCEPTION=[org.springframework.beans.factory.UnsatisfiedDependencyException] EXCEPTION_MSG=[Error creating bean with name 'someBean': Unsatisfied dependency expressed through field 'someOtherBean'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'someOtherBean' defined in class path resource [path/to/ResourceAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [path.to.resource.SomeOtherBean]: Circular reference involving containing bean 'someBean' - consider declaring the factory method as static for independence from its containing instance. Factory method 'someOtherBean' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aThirdBean': Requested bean is currently in creation: Is there an unresolvable circular reference?] ROOT_CAUSE=[org.springframework.beans.factory.BeanCurrentlyInCreationException] ROOT_CAUSE_MSG=[Error creating bean with name 'aThirdBean': Requested bean is currently in creation: Is there an unresolvable circular reference?] STACKTRACE=[org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
Comment From: snicoll
Thanks for the proposal @CC007 but we're not keen to do multi-lines logs and https://github.com/spring-projects/spring-framework/issues/25162 has improved the situation since the.