| Author |
How to select destination of stdout?
|
Jarrod Mennuobe
Greenhorn
Joined: Oct 05, 2005
Posts: 20
|
|
I'm trying to understand how to view System.out output when using Tomcat. When I start Tomcat, I open a DOS window and run Tomcat's startup.bat file. As a result, stack traces and other output does show up in a DOS window. However, I would like to send all that output to a text file. That will make it much easier to view it and work with it. The Tomcat docs say: "Tomcat 5.5 has done away with localhost_log which you may be familiar with as the runtime exception/stack trace log. These types of error are usually thrown by uncaught exceptions, but are still valuable to the developer. They can now be found in the stdout log." I looked in Tomcat's "logs" dir and throughout the Tomcat hierarchy for a file called "stdout" but there's nothing. The Tomcat docs omit the location and exact filename of "the stdout log". I did a search on this issue and found the advice to edit catalina.bat to specify where to send stdout. However, looking in catalina.bat, I can't find any code that appears to have anything to do with controlling the destination of stdout. I also tried using System.setOut() to specify a file for the output stream. No data appeared in the file. I would appreciate any useful help I can get to resolve this. My setup: Tomcat 5.5.9 Windows 2000 JDK 1.4.2
|
 |
Stian Almaas
Ranch Hand
Joined: Sep 22, 2005
Posts: 33
|
|
You could run startup.bat like this... startup.bat >> my.log That will redirect all output from startup.bat into the my.log file. But this will only work once since it will overwrite the file every time you run tomcat. I think what you have to do is start tomcat as a service. In that case you will use service.bat where you can set up a redirect for stdout.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
>> will append to an exising file or create it if it doesn't exist already. > will clobber the existing one.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Jarrod Mennuobe
Greenhorn
Joined: Oct 05, 2005
Posts: 20
|
|
Thanks for the replies. I tried starting Tomcat like this: startup.bat >> "C:\Program Files\Apache Software Foundation\Tomcat 5.5\logs\stdout.txt" I tried it with and without quotes around the path. An empty log file was created but nothing was written to it. All of Tomcat's startup ouput messages continued to go to the DOS console. I tried including a System.out.println() statement in my Java code but the output from that did not appear in the console or in the log file. Any idea what's going wrong here? Thanks, E
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
I haven't a Winders box at my disposal to try it but try adding the '>> logfile.log' to the execute line in catalina.bat. %_EXECJAVA% ...... %ACTION% >> logfile.log There's more than one of them. By the way: If you building anything more than a trivial app, you should really look into a logging package like log4j. It'll make your life a lot easier. [ October 06, 2005: Message edited by: Ben Souther ]
|
 |
 |
|
|
subject: How to select destination of stdout?
|
|
|