In my Spring Boot project, I encounter the following exception log during application startup while initializing annotations like @NamedQuery
:
java.lang.Exception: exception just for purpose of providing stack trace
Upon investigating the related class, I found that the buildNamedQuery
method is designed to always throw this exception at the end for stack trace purposes.
- In my project, I use JPA queries but do not utilize
@NamedQuery
annotations. Is there a way to suppress this exception log without relying on logger-level controls (e.g., usinglogback
)? Specifically, is there an application configuration option (e.g.,application.yml
) or another mechanism to handle this scenario more cleanly? - The reason for this inquiry is somewhat frustrating: our engineers often confuse “error” and “exception” in the logs, which leads to unnecessary concerns like, “Why is there an ‘error’ during server startup? Can you prove it’s not a real issue?” To avoid repeatedly explaining this, I’d like to provide them with technical references or official documentation to clarify that this log is benign.
Any guidance or recommendations would be greatly appreciated!