Bug 51347 - Filename and line number not display , Java version difference
Summary: Filename and line number not display , Java version difference
Status: NEW
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Appender (show other bugs)
Version: unspecified
Hardware: Other Windows XP
: P2 critical
Target Milestone: ---
Assignee: log4j-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-09 08:36 UTC by Indrojeet
Modified: 2011-06-15 05:03 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Indrojeet 2011-06-09 08:36:15 UTC
Log not getting printed properly when application run on a machine with
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode, sharing)
but the log is corrected generated when application is running on
java version "1.6.0_19"
Java(TM) SE Runtime Environment (build 1.6.0_19-b04)
Java HotSpot(TM) Client VM (build 16.2-b04, mixed mode, sharing)
or
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 16.2-b04, mixed mode, sharing)

---------
log4j.rootLogger=DEBUG, rolling
log4j.category.com.dataupload = INFO, rolling
log4j.category.org.xml.sax = INFO, rolling
log4j.category.org.hibernate = ERROR, rolling
log4j.appender.rolling=org.apache.log4j.RollingFileAppender
log4j.appender.rolling.file=D:/Log/Indro/logs/dua.log
log4j.appender.rolling.MaxFileSize=1000KB
log4j.appender.rolling.MaxBackupIndex=1
log4j.appender.rolling.layout=org.apache.log4j.PatternLayout
log4j.appender.rolling.layout.ConversionPattern=%d %-5p %5L:%27F %1x : %m%n

The above is my log4j.properties file.

Sample of the correct log file

2011-02-08 16:31:56,813 INFO     33:      FileHandler.java   : | | >readFiles
2011-02-08 16:31:56,828 INFO     61:      FileHandler.java   : | | <readFiles
2011-02-08 16:31:59,125 INFO     35:      MainClass.java   : | | >runParser


Sample of incorrect log file

2011-06-09 12:06:14,103 INFO      ?:                 ?   : ||||> isFileNameInDB
2011-06-09 12:06:16,837 INFO      ?:                 ?   : ||||> isFileNameInDB
2011-06-09 12:06:16,837 INFO      ?:                 ?   : ||||>deleteXMLFile

Basically the line number and Filename is getting replaced by ? symbol

I am using : log4j-1.2.15.jar 
Please let me know a fix to this issue, do let me know if any other information is also needed.
Comment 1 Curt Arnold 2011-06-15 05:03:27 UTC
File name and line number depend on debug information being present in the jar file.  If you are recompiling the classes or rebuilding the jar file on the other platform, then the problem is most likely that you are not compiling with debug information included in the jar.  

If you are not recompiling, please let us know any additional information that might assist.

Determining the file and line number requires generating an exception and then interrogating it.  When it works (which depends on the code being compiled with debugging info), it can be very expensive performance wise.  It is more efficient to depend on logger names and unique messages to identify the origin of the logging request.