I'm using slf4j to log custom exceptions and their stack traces in both console and a custom file. I met a situation that I had to truncate the stack traces of some non-critical exceptions.
Using this documentation, I added the following configuration in my logback.xml file
<evaluator name="DISPLAY_EX_EVAL">
<expression>throwable != null && throwable instanceof com.abc.NonCriticalException</expression>
</evaluator>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%-30(%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread]) %-5level
%logger{150} -%msg%n%ex{full, DISPLAY_EX_EVAL}
</pattern>
</encoder>
</appender>
But, the above configuration removes all the stacktraces during logging of the configured exception. Is there a way to log the truncated stack trace (1 or 2 lines) of the matched exception ?