3

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

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.

| improve this answer | |
  • This didn't work for me though :/ – Steven McConnon Feb 17 '15 at 21:23
  • Did not work though. w/ Tomcat 8 running on Windows as a service – Ach J Nov 21 '18 at 14:10
  • What does the 1 in 1catalina mean ? – Mehdi Feb 4 '19 at 18:49
5

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.

| improve this answer | |
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
| improve this answer | |
  • it's not work for me – popalka Mar 28 '11 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.

| improve this answer | |
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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.