I am trying to debug the value of an object in EJB
If I do logger.fine("foo")
, then I can see foo
, but if I do logger.fine("foo = " + bar)
then i cant see anything. So how do I debug in EJB? I am using netbean 6.8 btw
views:
48answers:
1
+1
A:
Are you sure bar.toString() is not throwing some runtime exception? Otherwise it should work.
Try a try...catch block around it to be sure.
vanza
2010-06-28 19:37:02
Thank you, I catch `NullPointerException`.
Harry Pham
2010-06-28 19:51:57
@Harry You don't need to allow the NullPointerException just so you can catch it; just check for null ahead of time. `logger.fine("foo = " + (bar == null ? "null" : bar))`
Michael Mrozek
2010-06-28 19:56:19
Thanks. What I mean before is since I catch `NullPointerException` I figure out what wrong with my code. It not because Java Logger cant print variable, it because my variable is `null`. Once I know that, then I start the tracing. It is fixed now. Thank you very much
Harry Pham
2010-06-28 20:20:41