Skip to content

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

Closed
@CC007

Description

@CC007

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fixstatus: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions