This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Servlets and the fly likes Debug in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Debug in servlet" Watch "Debug in servlet" New topic

Debug in servlet

kris reddy

Joined: Nov 07, 2000
Posts: 19
I am using apache tomcat for running servlets. I would like my servlet to print out some debug statements when it is executes. I have included some console output statements. I am not sure where to look for the debug output. Where are these debug statements getting printed?
Thanks in advance.
Have a good day,

Kris Lee
Julian Sitkevich

Joined: Jul 23, 2001
Posts: 19
You can look to the console or log, or you can code your own mechanism:

Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

It depends on how you've coded your debug statements.

If you use System.out or System.err then both of these are being redirected to the console window (on Windows) and I *think* to catalina_out on *nix.

But how about using the log() method provided by your servlet? This way, it doesn't clutter your console window, and it is accessed by looking at : /CATALINA_HOME/logs/localhost_log.2002-08-29.txt

example:You could also redirect System.err or System.out back to where you wanted... I haven't tried this though, and perhaps there will be permissions trouble with this:
java.lang.System.setOut(PrintStream out)
So you would supply it with a value for 'out' that you want.
I agree. Here's the link:
subject: Debug in servlet
It's not a secret anymore!