tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Muschko <>
Subject Embedded Tomcat 6 & 7 logging to file
Date Sun, 15 Jul 2012 22:57:11 GMT

I'd like to redirect the embedded Tomcat's startup logging messages to a
file. What I am looking for is something like this:

Initializing ProtocolHandler ["http-bio-8080"]
Initializing ProtocolHandler ["http-bio-8091"]
Starting service Tomcat
Starting Servlet Engine: Apache Tomcat/7.0.11

So far I haven't found a way of making this work. My first approach was to
add a FileHandler to the context's logger:

Handler fh = new FileHandler("output.log", true);
fh.formatter = new SimpleFormatter();
fh.level = Level.ALL;
fh.encoding = "UTF-8";

It works fine for the context in Tomcat 7 but doesn't give me the result I
am looking for.  Also trying to capture System.out and System.err and
writing it to a file doesn't solve my problem:

System.setOut(new PrintStream(new File("output-file.txt")));
System.setErr(new PrintStream(new File("output-file.txt")));

I guess I am not clear on how the embedded Tomcat implementation logs the
messages to the console and how I can change it. Could somebody clarify this
for me. It would be great to see and example that would work for embedded
Tomcat 6 & 7.



View this message in context:
Sent from the Tomcat - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message