aspose file tools*
The moose likes Tomcat and the fly likes how to redirect the tomcat (5.0) console output to a text file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "how to redirect the tomcat (5.0) console output to a text file" Watch "how to redirect the tomcat (5.0) console output to a text file" New topic
Author

how to redirect the tomcat (5.0) console output to a text file

Javoso Torso
Ranch Hand

Joined: Aug 15, 2003
Posts: 88
Hello,

I am looking for a way of redirecting the tomcat console output [the System.out.println("xyzabc")�s from the java classes running on the container] to a text file.

The reason is that the programmers need to have that console�s output and the server (windows) have to be rebooted often (no wonder: windows) and then Tomcat start as a service -> console is not visible.

Thanks!


I hate 'trial and error'<br />and I am doing it all the time
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
Does this answer your question?


Ping & DNS - updated with new look and Ping home screen widget
sudeep philip
Greenhorn

Joined: Nov 28, 2002
Posts: 5
The following is a batch file which starts tomcat and logs the console log into a file based on the system date.
Modify the java_home, tomcat directories and the command line to start tomcat as per your requirements. Hope this will help :-)
-----------------------------------------------------------------
@Echo Off
Goto Begin
Echo Writes to a log file with date and time stamp next
Echo to the specified command line parameter.
Echo.
Echo [CALL] LOG logfile [message to be written to logfile with time-stamp]
Echo.
Echo Specify CON as 'logfile' to print the message on the screen.
goto End
:Begin
:: set environment variable yyyymmdd to current yymmdd
for /f "tokens=2,3,4 delims=/-. " %%i in ('date/t') do set ddmmyyyy=%%j%%i%%k
Set Log="C:\Program Files\Apache Group\Tomcat 4.1\logs\console\%ddmmyyyy% console.log"
:Loop
set JAVA_HOME=D:\j2sdk1.4.2
set CLASSPATH=%JAVA_HOME%\jre\lib\rt.jar
echo ===============================================================================
echo .
echo Tomcat Environment
echo .
echo CATALINA_HOME: %CATALINA_HOME%
echo .
echo JAVA: %JAVA_HOME%
echo .
echo CLASSPATH: %CLASSPATH%
echo .
echo ===============================================================================
echo .
Set Msg=****************** Starting Tomcat 4.0 at :
Shift
If %2'==' Goto %OS%_Display
Goto Loop
:_Display
Echo @Prompt %%%%1 %%%%0 :: $D $T$_Echo %%%%3 %%%%4 %%%%Msg%%%%$G$G%%%%Log%%%%$_>%TEMP%.\$OW0.BAT
%COMSPEC% /C %TEMP%.\$OW0.BAT > %TEMP%.\$OW1.BAT
Call %TEMP%.\$OW1.BAT
Del %TEMP%.\$OW?.BAT
Goto End
:Windows_NT_Display
For /F "tokens=2" %%D In ('Date /T') Do For /F %%T In ('Time /T') Do (Echo %Msg% %%D %%T ****************** >>%Log%)
:End
C:\jdk1.3.1\bin\java.exe -jar -Duser.dir="C:\Program Files\Apache Group\Tomcat 4.1" "C:\Program Files\Apache Group\Tomcat 4.1\bin\bootstrap.jar" start >> %Log%
Set Msg=
Set Log=
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to redirect the tomcat (5.0) console output to a text file
 
Similar Threads
Mock exam question doubt?
Getting rid Struts [DEBUG] output (log4j)
not making the JSP pages visible using tomcat server
Tomcat, Log4J and Console Output in Eclipse
Eclipse console only 400 lines?