This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
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
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=