views:

55

answers:

3

I am specifying the below command in catalina.bat >

set JAVA_OPTS=-XX:+TraceClassLoading -XX:+TraceClassUnloading -XX:+PrintGCDetails

The logs are printed in console but i am not able to redirect the logs in file. Using startup.bat > logs.txt

Can anyone tell me how to save/trace the console logs??

+1  A: 

The easiest way around this is to change catalina.bat as follows:

You need to delete all the "start" commands (which are responsible for starting up tomcat in a separate window).

Example:

Change:

set _EXECJAVA=start "%TITLE%" %_RUNJAVA%

to

set _EXECJAVA=%_RUNJAVA%

You need to change all occurrences.

Once you have made this change, you can then redirect stdout as follows:

startup.bat > ..\logs\catalina.out

Another option is to create your own startup file, say mystartup.bat containing the following command:

java %JAVA_OPTS% -Djava.util.logging.config.file="%TOMCAT_HOME%\conf\logging.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager   -Djava.endorsed.dirs="%TOMCAT_HOME%\endorsed" -classpath "%TOMCAT_HOME%\bin\bootstrap.jar" -Dcatalina.base="%TOMCAT_HOME%" -Dcatalina.home="%TOMCAT_HOME%" -Djava.io.tmpdir="%TOMCAT_HOME%\temp" org.apache.catalina.startup.Bootstrap  start

and execute it:

mystartup.bat > ..\logs\catalina.out

(Thankfully, this problem does not exist in UNIX because the catalina.sh script automatically redirects stdout/stderr to $CATALINA_OUT)

dogbane
A: 

If you want to see the GC logging data alone in a separate file, it's also simple to add this flag to your JAVA_OPTS

-Xloggc:filename

So on windows, write to c:\gc.log as

-Xloggc:c:\gc.log
JoseK
A: 

The "script" utility (cygwin) can help you out.

Steps
1. Open command prompt.
2. Run this utility by giving a filename.
3. Run the .bat file to start the tomcat.

siddagrl