# How to redirect tomcat console log to files? Tomcat started via windows bat

When tomcat started as service it put his output log in \logs\stderr.log \logs\stdout.log

How to write this log files when tomcat started as bat in windows?

PS. 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

-

## migrated from stackoverflow.comMar 28 '11 at 22:39

This question came from our site for professional and enthusiast programmers.

Edit conf/logging.properties and change the 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..log, not to the console.

-
thanks, it's work –  popalka Mar 29 '11 at 5:03
This didn't work for me though :/ –  Steven McConnon Feb 17 at 21:23

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.

-

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

-
it's not work for me –  popalka Mar 28 '11 at 13:55

You will need to edit the Tomcat's startup bat file. Just use it like this in that bat file:

tomcat-start-command > \path\to\my\log\tomcat.log 2<&1


# Update:

If you start your tomcat process like this then both STDOUT and STDERR get redirected properly to ..\logs\console.log file:

cd "C:\Program Files\apache-tomcat-7.0.11\bin"
catalina run > ..\logs\console.log 2<&1

-
it's not work for me –  popalka Mar 28 '11 at 13:52
@popalka: That's the way STDOUT and STDERR are redirected to same file on Windows/DOS. Can you please show me your bat file so that I can help you better. –  anubhava Mar 28 '11 at 14:02
@popalka: Also please check or show me what is in startup batch file. That might have its own redirection directives. –  anubhava Mar 28 '11 at 14:09