Skip to content

Instantly share code, notes, and snippets.

@awood
Last active May 2, 2022 09:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awood/f3830acc6454f33640a4 to your computer and use it in GitHub Desktop.
Save awood/f3830acc6454f33640a4 to your computer and use it in GitHub Desktop.
Non-rotating Tomcat logging.
# In Fedora 20, Tomcat 7 has an annoying habit of creating log files that are named
# "catalina.YYYY-MM-DD.out" with the day's date filled in the file name. It is a pain in
# the neck to have to remember the date every time I want to look at the log file and
# tab completion doesn't help because it will only complete as far as the most common
# string which in the case of the date is usually the year.
# StackOverflow to the rescue: http://stackoverflow.com/questions/4511845
# My solution was slightly different though. I set "rotatable" to false, but instead of
# adding a "suffix" option in /etc/tomcat/logging.properties, I just changed the "prefix" option to
# remove the period.
# Then as the tomcat user, I created a symlink from catalina.out to catalina.log since that's where the
# messages go now.
# The second problem I have with Tomcat's logging is that it sends important messages to "localhost.log"
# which I never think to look at. This issue can be solved by setting the handler for "[Catalina].[localhost]
# to the 1catalina handler instead of the 2localhost handler.
# handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
handlers = 1catalina.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina
1catalina.org.apache.juli.FileHandler.rotatable = false
# 2localhost.org.apache.juli.FileHandler.level = FINE
# 2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
# 2localhost.org.apache.juli.FileHandler.prefix = localhost
# 2localhost.org.apache.juli.FileHandler.rotatable = false
3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.FileHandler.prefix = manager
3manager.org.apache.juli.FileHandler.rotatable = false
4host-manager.org.apache.juli.FileHandler.level = FINE
4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.FileHandler.prefix = host-manager
4host-manager.org.apache.juli.FileHandler.rotatable = false
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 1catalina.org.apache.juli.FileHandler
# org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.FileHandler
# For example, set the org.apache.catalina.util.LifecycleBase logger to log
# each component that extends LifecycleBase changing state:
#org.apache.catalina.util.LifecycleBase.level = FINE
# To see debug messages in TldLocationsCache, uncomment the following line:
#org.apache.jasper.compiler.TldLocationsCache.level = FINE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment