I remember there's a way for System.out output to a file, so it can be saved easily. does anyone know how?
THanks.
SCJP 1.4
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
posted
0
When you start Java from the command line you can redirect the output:
Once your code is running you can change where stdout goes
Does one of those do what you need?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Yan Bai
Ranch Hand
Joined: Jul 21, 2002
Posts: 125
posted
0
Thanks Stan. 1st one cannot be used coz it's a web application. I am curious about the 2nd option. how can it be used in a web environment? or is there a way to change the default output device from screen to something else?
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
What exactly do you need to do???
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Yan Bai
Ranch Hand
Joined: Jul 21, 2002
Posts: 125
posted
0
I have 'System.out' lines in jsp/servlet pages, for basic debug purpose. Since the default system.out and system.err devices are the screen, the output information I specified are all mixed with Tomcat's embedded msg.
I want to seperate the information, e.g. let Tomcat intact, but output my system.out to somewhere else, such as a plain text file.
Instead of writing a redirect program by my own, I remember there's a way to change teh default output device for JVM, but how? your inputs are very appreicated...
Yan Bai
Ranch Hand
Joined: Jul 21, 2002
Posts: 125
posted
0
Thanks Stan, the 2nd option works great.
Ramen Chatterjee
Ranch Hand
Joined: Apr 27, 2006
Posts: 62
posted
0
Hi
Just to clariy..
.. 1>stdout.txt 2>err.txt
First part means redirect std out to file Second part means redirect std error to file
BTW, if these are servlets why not use the log() method?
Regards
Ramen
Could try harder
manuel aldana
Ranch Hand
Joined: Dec 29, 2005
Posts: 308
posted
0
yes servlet-containers (like tomcat) use themselves logging frameworks. so go use them, too.
you really should avoid use System.out. for logging messages, soon or after it gets a pain: it's difficult to redirect it, no enforement of an output pattern, no simple switching off etc.