开发者

Redirect Tomcat 7 console log output to a file (Windows)

How do I redirect Tomcat 7 console log output to a file on Windo开发者_Python百科ws?


Using catalina.bat run can start the tomcat in the current console instead of a new console , so you can redirect all the standard error and standard output stream of this command to a file using

catalina.bat run > tomcat.log 2>&1


To get the Tomcat output and share it:: 1. Make a file " Start_Tomcat.bat " put the below lines in that.

cd C:\XXX\apache-tomcat-6.0.20\bin
        catalina.bat run > C:\XXX\apache-tomcat-6.0.20\logs\tomcat1.log 2>&1

NOTES:: C:\XXX\apache-tomcat-6.0.20\bin -- is the systems bin address " \logs\tomcat1.log 2>&1 " should not change...

    Ques:: What does the 2>&1 do?
    Ans:: 2>&1 means output only to file. Without that it would output to both text and console.
  1. Paste the file in the below location::: " C:\XXX\apache-tomcat-6.0.20\bin "

  2. Run " Startup.bat " & " Start_Tomcat.bat "

  3. You will get " C:\XXX\apache-tomcat-6.0.20\logs\tomcat1.log " . Share the "tomcat1.log" file so others can see your tomcat responses.


File: catalina.bat (in the Tomcat's root \bin directory)

Lines:

rem Comment out the line below
rem set _EXECJAVA=start "%TITLE%" %_RUNJAVA%
rem Add the line below instead
set _EXECJAVA=%_RUNJAVA%

Next, find the line making the final Java call (add the redirection as below):

%_EXECJAVA% %CATALINA_LOGGING_CONFIG% %LOGGING_MANAGER% ... 2>&1 >c:\temp\tomcat.log

You will then get your stdout and stderr streams in the file c:\temp\tomcat.log

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜