• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdk 1.4: when does the logging shorthand fail ?

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In sun's sdk 1.4 documentation on logging, they say:
"void warning(String msg);
For this second set of methods, the Logging framework will make a "best effort" to determine which class and method called into the logging framework [...]. However, it is important to realize that this automatically inferred information may only be approximate. The latest
generation of virtual machines perform extensive optimizations when JITing and may entirely remove stack frames, making it impossible to reliably locate the calling class and method. "
so, when is this short version reliable ? is it only problematic with JIT compiler or are there other critical issues ?
if detecting the method is not reliable, where's the point of this framework at all ?
thank y'all
dennis
 
Thomas Smets
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dennis,
Be professionnal use Log4J. It's a technology from I.B.M. given in GPL ... What else do you want ?
Thomas,
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dennis,
the framework is just giving you the choice: Either do some more work and get the most precision, or use the automated mechanism and live with the potential impreciseness.
Thomas,
are you implying that using the JDK1.4 logging framework would be nonprofessional???
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys !
gonna use log4j
dennis
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dennis K�hn:
gonna use log4j

Aha, why?
Please notice that log4j doesn't seem to give you the option to explicitely name the source of a log event, so it always works in the imprecise mode that the JDK1.4 mechanism gives you as an option.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seen from this point, you're right.
The company I work for has just managed to make their way to jdk 1.3. It will be at least one more year until 1.4 will be a strategic release here.
I would have extracted the logging from the 1.4 runtime jar, but it doesn't work (can't recompile it under 1.3) because sun, who are getting as nasty as M$, "forgot" to include them sun.reflect sources in the 1.4 src, which are required for the logging to work.
instead of adapting all that shid and still not having method names logged, it takes less to just use a 3rd party product and use clear ifaces where application and logging controls meet the actual logging mechanism, so i still can change easily to the 1.4-built-in jdk logging.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There seems to be an open source implementation of the java logging framework for JDK1.2: http://sourceforge.net/projects/javalogging/
Might be worth a look.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yep- that seems great to me. having the same interface before and after jdk 1.4 is of great value !
thanks for the hint !
greetz
dennis
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic