logger.error()打印异常堆栈信息

大家知道  e.printStackTrace()  可以打印异常堆栈信息 ,那么 logger.error() 怎么输出呢

 正确写法

 try {
        
 } catch (ArgsException e) {
      logger.error("异常",e);
 }

错误写法

      logger.error(e.getMessage());

      logger.error(e.toString());

      logger.error("异常" + e);

 

 

看源码

/**
     * Log a message at the ERROR level.
     *
     * @param msg the message string to be logged
     */
    public void error(String msg);

 

 /**
     * Log an exception (throwable) at the ERROR level with an
     * accompanying message.
     *
     * @param msg the message accompanying the exception
     * @param t   the exception (throwable) to log
     */
    public void error(String msg, Throwable t);

 可以看出如果传入字符串是不会打印异常信息的

 

 

 

 

 

 

 


心到抢票    心到抢票  https://www.xdticket.com/

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值