views:

48

answers:

1

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

+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
Thank you, I catch `NullPointerException`.
Harry Pham
@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
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