美文网首页
scala sorg.slf4j.{Logger, Logger

scala sorg.slf4j.{Logger, Logger

作者: 邵红晓 | 来源:发表于2019-12-19 17:31 被阅读0次

    错误
    logger.warn("table为null,actionType:{},original:{}",actionType,value.getOriginal)

    Error:(70, 14) ambiguous reference to overloaded definition,
    both method warn in trait Logger of type (x$1: String, x$2: Any, x$3: Any)Unit
    and  method warn in trait Logger of type (x$1: String, x$2: Object*)Unit
    match argument types (String,String,String)
          logger.warn("table为null,actionType:{},original:{}",actionType,value.getOriginal)
    

    正确:
    logger.warn("table为null,actionType:{},original:{}",Array(actionType,value.getOriginal):_*)

    slf4j 正确的日志打印异常堆栈的方式

    @Test
    public void testError() {
        String s = null;
        try {
            s.length();
        } catch (Exception e) {
            log.error(s, e);
            //当然如果你懒得想提示信息的话,直接这样log.error("", e);
        }
    }
    

    相关文章

      网友评论

          本文标题:scala sorg.slf4j.{Logger, Logger

          本文链接:https://www.haomeiwen.com/subject/yucvnctx.html