You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Louis Voo <lo...@allsofts.com> on 2002/05/02 09:16:57 UTC

How to redirect the log file from the command window to a file?

Hi,

    I'm using tomcat 4.04b2 for window.  After I start my tomcat, all the
system.out log will print out in that command window, can I redirect it to a
file?  Please tell me  how to do that.


Thank you

Louis



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: How to redirect the log file from the command window to a file?

Posted by David Rault <to...@free.fr>.
you still have output on the console because you redirect the standard
output to your file (see the '> %ACTION%-server.log' ?)
the remaining output is most surely the error output which you might also
want to redirect to your file
i don't know the windows command
for linux, i add '2>&1' before the classic redirect
that tells the system to redirect the second output (ie the error output) to
the 1st output (ie the standard output)
somepath/mycommand 2>&1 > someotherpath/mylogfile

you can also separate the files
somepath/mycommand 2>  someotherpath/errorlog > someotherpath/standardlog

another solution would be to tell java that System.out and System.err must
be redirected to a file
see java.lang.System javadoc, i know there is a setter for both streams
something like
System.setOut(new java.io.FileWriter("somepath/somefile");
System.setErr(new java.io.FileWriter("somepath/someotherfile");

bye
David
----- Original Message -----
From: "Louis Voo" <lo...@allsofts.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>;
<jo...@mkodo.com>
Sent: Thursday, May 02, 2002 3:21 PM
Subject: Re: How to redirect the log file from the command window to a file?


> Hi Jon
>         Thanks for your tip, but I still got problem, the start-server.log
> file is created, but no content in it, there are many print out from the
> command window, but the file is still empty.  Somewhere goes wrong?
>
>
> Louis
> ----- Original Message -----
> From: "Jon Wingfield" <jo...@mkodo.com>
> To: "Tomcat Users List" <to...@jakarta.apache.org>
> Sent: Thursday, May 02, 2002 12:01 PM
> Subject: RE: How to redirect the log file from the command window to a
file?
>
>
> > 1) alter the catalina.bat file:
> >
> > ... extract ...
> > %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS%
> > %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath
> >
>
"%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_H
> > OME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS%
> > %ACTION% > %ACTION%-server.log
> > ... extract end ...
> >
> > this puts all the system.out into a file start-server.log in the tomcat
> bin
> > directory.
> >
> > 2) use the jakarta log4j logging package with a ConsoleAppender ;)
> >
> > Hope this helps,
> >
> > Jon
> >
> > -----Original Message-----
> > From: Louis Voo [mailto:louis@allsofts.com]
> > Sent: 02 May 2002 08:17
> > To: Tomcat Users List
> > Subject: How to redirect the log file from the command window to a file?
> >
> >
> > Hi,
> >
> >     I'm using tomcat 4.04b2 for window.  After I start my tomcat, all
the
> > system.out log will print out in that command window, can I redirect it
to
> a
> > file?  Please tell me  how to do that.
> >
> >
> > Thank you
> >
> > Louis
> >
> >
> >
> > --
> > To unsubscribe:   <ma...@jakarta.apache.org>
> > For additional commands: <ma...@jakarta.apache.org>
> > Troubles with the list: <ma...@jakarta.apache.org>
> >
> >
> >
> > --
> > To unsubscribe:   <ma...@jakarta.apache.org>
> > For additional commands: <ma...@jakarta.apache.org>
> > Troubles with the list: <ma...@jakarta.apache.org>
> >
>
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>
>



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: How to redirect the log file from the command window to a file?

Posted by Louis Voo <lo...@allsofts.com>.
Hi Jon
        Thanks for your tip, but I still got problem, the start-server.log
file is created, but no content in it, there are many print out from the
command window, but the file is still empty.  Somewhere goes wrong?


Louis
----- Original Message -----
From: "Jon Wingfield" <jo...@mkodo.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Thursday, May 02, 2002 12:01 PM
Subject: RE: How to redirect the log file from the command window to a file?


> 1) alter the catalina.bat file:
>
> ... extract ...
> %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS%
> %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath
>
"%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_H
> OME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS%
> %ACTION% > %ACTION%-server.log
> ... extract end ...
>
> this puts all the system.out into a file start-server.log in the tomcat
bin
> directory.
>
> 2) use the jakarta log4j logging package with a ConsoleAppender ;)
>
> Hope this helps,
>
> Jon
>
> -----Original Message-----
> From: Louis Voo [mailto:louis@allsofts.com]
> Sent: 02 May 2002 08:17
> To: Tomcat Users List
> Subject: How to redirect the log file from the command window to a file?
>
>
> Hi,
>
>     I'm using tomcat 4.04b2 for window.  After I start my tomcat, all the
> system.out log will print out in that command window, can I redirect it to
a
> file?  Please tell me  how to do that.
>
>
> Thank you
>
> Louis
>
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


RE: How to redirect the log file from the command window to a file?

Posted by Jon Wingfield <jo...@mkodo.com>.
1) alter the catalina.bat file:

... extract ...
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS%
%DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath
"%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_H
OME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS%
%ACTION% > %ACTION%-server.log
... extract end ...

this puts all the system.out into a file start-server.log in the tomcat bin
directory.

2) use the jakarta log4j logging package with a ConsoleAppender ;)

Hope this helps,

Jon

-----Original Message-----
From: Louis Voo [mailto:louis@allsofts.com]
Sent: 02 May 2002 08:17
To: Tomcat Users List
Subject: How to redirect the log file from the command window to a file?


Hi,

    I'm using tomcat 4.04b2 for window.  After I start my tomcat, all the
system.out log will print out in that command window, can I redirect it to a
file?  Please tell me  how to do that.


Thank you

Louis



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>