Skip to content

Log the bean exception trace as a multi line log #23227

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 Jul 2, 2019 · 1 comment
Closed

Log the bean exception trace as a multi line log #23227

CC007 opened this issue Jul 2, 2019 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@CC007
Copy link

CC007 commented Jul 2, 2019

(As requested, moved from the issue at Spring Boot: spring-projects/spring-boot#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)
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 2, 2019
@jhoeller jhoeller self-assigned this Jul 2, 2019
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Jul 3, 2019
@sbrannen sbrannen changed the title Enhancement: Log the bean exception trace as a multi line log Log the bean exception trace as a multi line log Jul 3, 2019
@snicoll
Copy link
Member

snicoll commented Aug 23, 2023

Thanks for the proposal @CC007 but we're not keen to do multi-lines logs and #25162 has improved the situation since the.

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Aug 23, 2023
@snicoll snicoll added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants