Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

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

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does this answer your question?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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=
 
reply
    Bookmark Topic Watch Topic
  • New Topic