1

I have a legacy service which runs on a tomcat server. I do not want to touch this service(I'm not sure how I would) but I know that this service prints a lot of logs on the tomcat server console(the console which comes up when we run startup.bat). I think these logs are causing the service to become slow, and I want to somehow configure the tomcat server such that the webapps running on the tomcat server do not print any logs on the console. I don't want to change the service if possible. Any help appreciated.

2 Answers2

0

Turning off logging altogether is generally a bad idea. There is some guidance in this post: How to stop Tomcat logging?

You could also try decreasing the logging detail level to filter out all but the SEVERE logs, so that if something bad does happen down the road, at least the SEVERE messages might help point you in the right direction. The Tomcat documentation available at http://tomcat.apache.org would be helpful if you want to try adjusting the logging detail level.

Andrew_CSE
  • 351
  • 2
  • 6
0

The logging of the Tomcat server can be configured in the [conf/logging.properties] (https://github.com/apache/tomcat/blob/master/conf/logging.properties) file by removing the java.util.logging.ConsoleHandler handler. Modify the line:

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

to

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

This is actually a good practice for production servers:

The default logging configuration in Apache Tomcat writes the same messages to the console and to a log file. This is great when using Tomcat for development, but usually is not needed in production.

(cf. Logging in Tomcat)

However the Tomcat server itself is not very verbose in its logging messages. The amount of data written to the standard output/error is probably due to:

  • old applications which "log" to System.out/System.err instead of a proper logging framework. In Tomcat you can redirect those messages to the proper log files setting the swallowOutput property of a context to true (see this question),
  • other logging frameworks like Log4j or Logback, configured to log to the standard output/error. For these you'll just have to modify their configuration files.
Piotr P. Karwasz
  • 12,857
  • 3
  • 20
  • 43