Is there a way in Spring Boot (mvc) to log a custom exception and throw it without its stack trace being visible in the log file? But for any other exception st
If you don't need the stack trace you can suppress the stack trace by overriding fillInStackTrace
in your exception class.
public class DuplicateFoundException extends RuntimeException {
@Override
public synchronized Throwable fillInStackTrace() {
return this;
}
}
When you invoke e.printStackTrace()
then no stack trace will be printed.
See also this blog post.