Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to configure my tomcat to rollover log files once a size limit is reached. I'm running tomcat as a windows service and am redirecting all my stdout to catalina.log. This is how I configured by logging.properties to set a size limit. But it is not working.

logging.properties

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, 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 = e:/apache-tomcat/logs/server_111-1001
1catalina.org.apache.juli.FileHandler.prefix = catalina.
1catalina.org.apache.juli.FileHandler.limit = 100000 # size 100kb 
1catalina.org.apache.juli.FileHandler.count = 5


2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = e:/apache-tomcat/logs/server_111-1001
2localhost.org.apache.juli.FileHandler.prefix = localhost.

3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = e:/apache-tomcat/logs/server_111-1001
3manager.org.apache.juli.FileHandler.prefix = manager.

4host-manager.org.apache.juli.FileHandler.level = FINE
4host-manager.org.apache.juli.FileHandler.directory = e:/apache-tomcat/logs/server_111-1001
4host-manager.org.apache.juli.FileHandler.prefix = host-manager.

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 = 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 com.xyz.foo logger to only log SEVERE
# messages:
#org.apache.catalina.startup.ContextConfig.level = FINE
#org.apache.catalina.startup.HostConfig.level = FINE
#org.apache.catalina.session.ManagerBase.level = FINE
#org.apache.catalina.core.AprLifecycleListener.level=FINE

But 1catalina.org.apache.juli.FileHandler.limit = 100000 doesn't seem to be working

share|improve this question
    
Never used tomcat on windows, but I think this is just stdout/stderr and they aren't redirected in the logging.properties. You can check that if you change the file location in logging.properties. See http://tomcat.apache.org/tomcat-6.0-doc/logging.html In my view you need a windows solution for logrotation like http://www.sprint.net.au/~terbut/usefulbox/apachelogrot.htm or fiddle with the tomcat service to redirect it to eventlog. –  AndreasM Feb 10 '12 at 15:56
    
I'm actually redirecting the stdout/stderr messages to catalina.log with giveing swallowoutput=true in context element of server.xml. –  Srinivas Feb 10 '12 at 16:08

1 Answer 1

You are using the FileHandler, documented here: http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/juli/FileHandler.html It does not have a "limit" property, it only rotates at day changes.

You can configure tomcat to use log4j which is more flexible, see this page: http://tomcat.apache.org/tomcat-6.0-doc/logging.html#Using_Log4j

swallowOutput in context is not recommended for use (that's what the above page says)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.