java 行号不显示?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9937485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Line number not showing?
提问by Hei
I have discovered some issues in my program.
I was using log4j for logging,
however, inside the log file, all line number become "?".
我在我的程序中发现了一些问题。
我使用 log4j 进行日志记录,
但是,在日志文件中,所有行号都变为“?”。
The conversation pattern is as follow:
对话模式如下:
log4j.appender.file.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss,SSS} %5p %c: %L - %m%n
回答by Svilen
You are most probably missing debug information in your compiled artifacts. I.e. it is not log4j's fault, you need to make sure you are compiling your stuff with debug information included. A quick test would be to try and debug your app with your favourite IDE. If there is no debug info it will complain and won't establish debug session...
您很可能在编译的工件中缺少调试信息。也就是说,这不是 log4j 的错,您需要确保您正在编译包含调试信息的内容。一个快速测试是尝试使用您最喜欢的 IDE 调试您的应用程序。如果没有调试信息,它会抱怨并且不会建立调试会话......
回答by quaylar
Set the options debug="true" debuglevel="lines,source"
in your javac ant-task.
debug="true" debuglevel="lines,source"
在 javac ant-task 中设置选项。
回答by Yogesh Prajapati
Check once.
i am using your pattern i my code,
and it works better....this is a log4j.properties
file.
检查一次。我在我的代码中使用你的模式,它工作得更好......这是一个log4j.properties
文件。
log4j.rootLogger=DEBUG
# AdminFileAppender - used to log messages in the admin.log file.
log4j.appender.AdminFileAppender=org.apache.log4j.FileAppender
log4j.appender.AdminFileAppender.File=admin.log
log4j.appender.AdminFileAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.ReportFileAppender.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss,SSS} %5p %c: %L - %m%n
#log4j.appender.AdminFileAppender.layout.ConversionPattern=%L - %r %-5p %c %x - %m - %d - %t%n
# ReportFileAppender - used to log messages in the report.log file.
log4j.appender.ReportFileAppender=org.apache.log4j.FileAppender
log4j.appender.ReportFileAppender.File=report.log
log4j.appender.ReportFileAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.ReportFileAppender.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss,SSS} %5p %c: %L - %m%n
#log4j.appender.ReportFileAppender.layout.ConversionPattern=%L - %r %-5p %c %x - %m - %d- %t%n
log4j.logger.com.vaannila.admin=,AdminFileAppender
log4j.logger.com.vaannila.report=,ReportFileAppender