Skip to content

Enhancement: Log the bean exception trace as a multi line log #17343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
CC007 opened this issue Jun 28, 2019 · 1 comment
Closed

Enhancement: Log the bean exception trace as a multi line log #17343

CC007 opened this issue Jun 28, 2019 · 1 comment
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid

Comments

@CC007
Copy link

CC007 commented Jun 28, 2019

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)
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 28, 2019
@wilkinsona
Copy link
Member

Thanks for the suggestion. The exceptions in question are part of Spring Framework and the form that their messages take is out of Spring Boot's control. If you'd like to pursue this, please open a Spring Framework issue.

@wilkinsona wilkinsona added for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants