我使用以下代码来打印 try catch 块中发生的任何异常,但是当异常发生时 logback 不会打印完整的堆栈跟踪,而是写入一行错误(没有明确说明导致它的原因. 如何在 logback 输出中打印出完整的堆栈跟踪?
Try 捕获异常的 catch 块
try {
// Create JMS objects
context = cf.createContext();
destination = context.createQueue("queue:///" + QUEUE_NAME);
((MQDestination)destination).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ);
} catch (Exception e) {
// catch any exception occurred while trying to connect to the destination queue Manager
e.printStackTrace();
LOGGER.info(e.toString());
return "Unable to connect to the destination queue Manager '"+QMGR +"'";
}
Run Code Online (Sandbox Code Playgroud)
重新登录错误输出:
21:18:10.748 [http-nio-8010-exec-4] INFO com.mqMessageHandler.Webcontroller - com.ibm.msg.client.jms.DetailedJMSRuntimeException: JMSWMQ0018: Failed to connect to queue manager 'KAU.TST' with connection mode 'Client' …Run Code Online (Sandbox Code Playgroud)