On 23.03.2022 12:11, Rony G. Flatscher (Apache) wrote: > On 23.03.2022 11:51, Konstantin Kolinko wrote: >> вт, 22 мар. 2022 г. в 20:21, Rony G. Flatscher (Apache) <r...@apache.org>: >>> For debugging purposes I downloaded the zip-version of Tomcat 10.0.18 and >>> start it up using >>> %CATALINA_HOME%\bin\startup.bat. >>> >>> <skip> >>> >>> Probably I have been doing something wrong in the past hours and not seeing >>> the forest for the trees >>> anymore I kindly request help: what is needed to successfully redirect >>> stderr and stdout to >>> %CATALINA_HOME%\logs after unzipping Tomcat 10 and starting it on Windows >>> using >>> %CATALINA_HOME%\bin\startup.bat? >>> >>> TIA for any help/pointer! >> First, I second Chris's answer >> >> вт, 22 мар. 2022 г. в 22:19, Christopher Schultz >> <ch...@christopherschultz.net>: >>> <skip> >>> >>> ... Windows CAN redirect both stdout and stderr to >>> two different places, and also to combine them just like you can on *nix: >>> >>> bin\catalina.bat run 2>&1 > stdout_stderr.log >>> >>> https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490982(v=technet.10)?redirectedfrom=MSDN >>> >> Note that >> "startup.bat" is an equivalent of calling "catalina.bat start". >> "shutdown.bat" is an equivalent of "catalina.bat stop". >> >> The above command (with " run") is a different one: >> it starts Tomcat in the same console window, as opposed to " start" >> that opens a new console window. >> >> Second, >> To redirect java.util.logging output to a file, replace ConsoleHandler >> in conf/logging.properties with a FileHandler that writes all those >> log lines to a file. >> >> Actually, logging.properties already has such a FileHandler >> configured. See the following line: >> >> .handlers = 1catalina.org.apache.juli.AsyncFileHandler, >> java.util.logging.ConsoleHandler >> >> It configures handlers for "." (the root). So all the same information >> is also being written to a "1catalina" FileHandler. Removing the >> "ConsoleHandler" from that line will stop duplicating all those log >> messages to the console. > The %CATALINA_HOME%\conf\logging.properties got changed according to > <https://serverfault.com/questions/252934/how-to-redirect-tomcat-console-log-to-files-tomcat-started-via-windows-bat> > as: > > handlers = 1catalina.org.apache.juli.AsyncFileHandler, > 2localhost.org.apache.juli.AsyncFileHandler, > 3manager.org.apache.juli.Async > FileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, > java.util.logging.ConsoleHandler > > # .handlers = 1catalina.org.apache.juli.AsyncFileHandler, > java.util.logging.ConsoleHandler > > .handlers = 1catalina.org.apache.juli.AsyncFileHandler > > ... cut ... > > Still stdout and stderr goes to the console. The redirection "2>&1 >test.log" > creates the empty file > but no output is there. > >> Third, >> If you app is actually calling System.err.println(), see about >> "swallowOutput" setting here >> https://tomcat.apache.org/tomcat-10.0-doc/logging.html#Console >> https://tomcat.apache.org/tomcat-10.0-doc/config/context.html > Will try that next thank you!
Tried two ways: * %CATALINA_HOME%\conf\context.xml adding attribute, so "<Context swallowOutput="true" ..." * adding a context.xml to %CATALINA_HOME%\webapps\testapp\META-INF\context.xml consisting of "<Context swallowOutput="true"></Context> only Did not make a difference. Having permutated so many different things I will delete everything and start over with a pristine unzipped Tomcat 10 to see if that makes a difference. ---rony