This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
What's the best way to debug a servlet under Tomcat when you don't have access to the STDERR.LOG and STDOUT.LOG files (or catalina.log) files? The way I normally debug a servlet is to look at the STDOUT.LOG files for the output of my System.out.println() commands. However, since I don't have access to these logs on the commercial web server, this approach won't work. Is a good way to just write to a text file on the web server (in a directory you do have rights to) using java File classes? I'm interested to hear any thoughts or ideas to debug a servlet that works fine under localhost, but fails on the actual web server (where I don't ahve access to the logs I need). Thanks in advance to all! -- Mike
For one suggestion - if you are just serving HTML - make sure every exception in your doGet or doPost is caught and try to return a HTML page with the full stack trace. (Hint - format with < pre > Bill
Joined: Jul 12, 2002
Hi Bill, Sorry, not so simple. The code that doesn't work on the web server is a class that generates JPEG files....no doGet() or doPut() in scope, unfortunately. Do you think creating a local file from the JPEG writer class based on what's happening in the JPEG-writer class (for example "You're now about to execute the write" type messages). Look forward to your reply.
Author and all-around good cowpoke
Joined: Mar 22, 2000
I think I would write a log to a StringWriter and make the resulting String accessible to another servlet or possibly to another function in the same servlet. So if your JPG generator serves an image on doGet you could add a doPost that shows the most recent log string. I have occasionally had debugging functions built in to servlets this way - naturally with some sort of password required. Bill