log的info、error打印的是对象还是toString

都是调用对象的toString方法,如果没有重写toString,则调用顶级父类Object的toString,
Hello hello=new hello();
LOGGER.info("hello:{}",hello);
LOGGER.error("hello:{}",hello,e);
System.out.println(hello);
    public String toString() {
        return getClass().getName() + "@" + Integer.toHexString(hashCode());
    }

Supongo que te gusta

Origin blog.csdn.net/sunyufeng22/article/details/120730043
Recomendado
Clasificación