Line number not showing?

半腔热情 提交于 2020-01-14 09:54:35

问题


I have discovered some issues in my program.
I was using log4j for logging,
however, inside the log file, all line number become "?".

The conversation pattern is as follow:

log4j.appender.file.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss,SSS} %5p %c: %L - %m%n

回答1:


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...




回答2:


Set the options debug="true" debuglevel="lines,source" in your javac ant-task.




回答3:


Check once. i am using your pattern i my code, and it works better....this is a log4j.properties file.

  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


来源:https://stackoverflow.com/questions/9937485/line-number-not-showing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!