5

When Tomcat is started as service it puts its output log in:

\logs\stderr.log  
\logs\stdout.log 

How to write this log files when Tomcat started as BAT in windows?

P.S.: I tried to start Tomcat with:

call startup > ../logs/consolelog.log 2<&1

But output of consolelog.log has only 5 lines

Using CATALINA_BASE:   "C:\Java\Tomcat 5.0"
Using CATALINA_HOME:   "C:\Java\Tomcat 5.0"
Using CATALINA_TMPDIR: "C:\Java\Tomcat 5.0\temp"
Using JRE_HOME:        "C:\Program Files\Java\jdk1.5.0_22"
Using CLASSPATH:       "C:\Java\Tomcat 5.0\bin\bootstrap.jar"

and lot of output in console

6 Answers 6

1

Edit conf/logging.properties and change this line

.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

to

.handlers = 1catalina.org.apache.juli.FileHandler

Then it will only log to catalina.<date>.log, not to the console.

3
  • This didn't work for me though :/ Feb 17, 2015 at 21:23
  • Did not work though. w/ Tomcat 8 running on Windows as a service
    – Ach J
    Nov 21, 2018 at 14:10
  • What does the 1 in 1catalina mean ?
    – Mehdi
    Feb 4, 2019 at 18:49
6

For those to which the accepted answer does not work:

I had the same situation, but I was using (liferay -> tomcat) startup.bat and it always opened up tomcat console. The way to edit the startup.bat file, so that it outputs the log into a file was like this:

Look for the line:

call "%EXECUTABLE%" start %CMD_LINE_ARGS% 

and edit it, so it looks like this:

call "%EXECUTABLE%" run >..\logs\outputfile.log 2>&1 start %CMD_LINE_ARGS% run >..\logs\outputfile.log 2>&1  

You can find your output in the tomcat's logs folder. The file is outputfile.log. The solution is an experimentation with what I found on this page, which was linked from this forum. Good luck.

0

I didn't double check, but I think you can just redirect the console I/O in a standard Windows and Unix manner:

tomcart-start > C:\mylog\log.txt
1
  • it's not work for me
    – popalka
    Mar 28, 2011 at 13:55
0

I have updated the startup.bat

call "%EXECUTABLE%" jpda run >..\logs\server.log 2>&1 start %CMD_LINE_ARGS% >..\logs\server.log 2>&1

Works for me.

0

As far as I understand, in your case I would not use call startup.

Try:

catalina run > ..\logs\consolelog.all 2>&1

or

catalina run > ..\logs\consolelog.out 2> ..\logs\consolelog.err

call startup at the end calls catalina start, which starts a new console. On the other hand catalina run runs in the same console, and you can redirect your stdout, stderr as you wish.

0

File: catalina.bat

Lines:

rem Comment out the line below like in this script extract
rem set _EXECJAVA=start "%TITLE%" %_RUNJAVA%
rem Add instead replace it with
set _EXECJAVA=%_RUNJAVA%

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

%_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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .