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.
I am using Apache Tomcat v 1.3.x. I would like to route all my System.out.println messages to a system file. How do I configure this? I don't want to make any changes to my JSP/Java files. Currently, the messages go to the console and I can't really track what's happening Can you please help me out?
As for system.out, this is a poor choice for doing debugging / logging.
System.out is *supposed* to go to the console. Were you expecting anything else? Log4j is highly recommended in these situations. You can configure individual packages and classes to produce output at separate levels. This is the way to go.
If you just don't want to change anything though... you'll have to use Tomcat's "swallowOutput" configuration. This will redirect System.out to the log file that is configured for your host. Though if you're truly using Tomcat 1.3, I wouldn't know how to do that for this version.
Use of System.out and System.err for tracing and logging is a practice highly to be discouraged. Not all appservers send the System outputs to the same places - I've seen specifically differences between where stuff goes in Solaris Tomcat vs. Linux Tomcat. And some appservers may lose the output entirely or scramble System.out and System.err together.
Of course it usually works, and I do it for quick-and-dirty stuff, but I don't do it for production apps, and never for something I expect to be portable.
Tomcat has some very extensive logging abilities attached to its Valve components. I recommend you read up on them and see if you find something you like. If you don't like them, of course, you can write your own Valve to log the way you do like.
The actual application logging itself is supported as part of J2EE, JDK 1.4 and later, and various 3d-party add-ons such as log4j. You can start out simple by just using Servlet.log() and add more complex loggers as/if needed.
And, BTW, note that there's a version of Servlet.log that allows you to log Exceptions, so you can capture stack traces!
An IDE is no substitute for an Intelligent Developer.