Log4j无法打印完整的堆栈跟踪 [英] Log4j not printing complete stack trace

查看:600
本文介绍了Log4j无法打印完整的堆栈跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我检查了SO中的所有答案.但是没有人真正帮助过我.

I checked all the answers in the SO. But none really helped me.

我的Log4j属性文件

log4j.rootLogger=debug,console,file

log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d %5p [%t] (%F:%L) - %m%n

log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=eseries.log
log4j.appender.file.MaxFileSize=1KB
log4j.appender.file.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.file.layout.ConversionPattern=%d %5p [%t] (%F:%L) - %m%n %throwable{short}

我的log4j版本

<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.11</version>
  </dependency>

登录格式

    logger.error("*****Error Id is:"+errorId+"\t" , e);

我得到的东西

我只是在日志中得到e.getMessage().不是完整的日志跟踪.

I am just getting the e.getMessage() in the log. Not the complete log trace.

有什么建议吗?

推荐答案

这是由于您的转换模式

 log4j.appender.file.layout.ConversionPattern=%d %5p [%t] (%F:%L) - %m%n %throwable{short}

这里摘录自ThrowableInformationPatternConverter

输出LoggingEvent的ThrowableInformation部分.经过 默认情况下,输出完整的堆栈跟踪.

Outputs the ThrowableInformation portion of the LoggingEvent. By default, outputs the full stack trace.

%throwable {none}或%throwable {0} 禁止堆栈跟踪.

%throwable {short}或%throwable {1} 仅输出第一行.

%throwable {n} 将为正整数输出n行,或为负整数输出最后-n行.

%throwable{n} will output n lines for a positive integer or drop the last -n lines for a negative integer.

您需要删除%throwable{short}才能查看完整的堆栈跟踪记录

You need to remove %throwable{short} to see full stack trace

这篇关于Log4j无法打印完整的堆栈跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆