开发者

Knowing class loading and unloading in tomcat

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?


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)


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜