How to verify (with unit test) that error stack is printed in the log file?
问题 In continuing to this answer I wrote a unit test to verify that in case of error, the stack will be printed in the log file. The tested method: import org.slf4j.Logger; import org.slf4j.LoggerFactory; private final Logger logger = LoggerFactory.getLogger(getClass()); public long getFq(String fi) { try { return calcSomeThing(fi.toLowerCase()); } catch (Exception e) { logger.error("unable to calculate SomeThing. Error: " , e); return -1; } } The unit test: import ch.qos.logback.classic.Level;