How do I redirect Tomcat 7 console log output to a file on Windows?
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
catalina.bat
is inside the bin
folder –
Sergei catalina.bat
inside the bin
folder –
Sergei 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.
Paste the file in the below location::: " C:\XXX\apache-tomcat-6.0.20\bin "
Run " Startup.bat " & " Start_Tomcat.bat "
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
© 2022 - 2024 — McMap. All rights reserved.