I am running the mvn tomcat:run-war target, and get a directory structure that has a logs directory. But alas, no log. I would just replace this with log4j logging, but this has proven difficult for a variety of reasons.
I have tried explicitly setting the log file configuration. My pom.xml definition currently looks like:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<port>8084</port>
<systemProperties>
<java.util.logging.config.file>${basedir}/src/main/webapp/WEB-INF/logging.properties</java.util.logging.config.file>
</systemProperties>
</configuration>
<version>1.1</version>
</plugin>
I see during startup that the property is being read. My properties file is below; I am dumping things to /tmp just to be sure I know where to look.
handlers = 1catalina.org.apache.juli.FileHandler, \
2localhost.org.apache.juli.FileHandler, \
3manager.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 = /tmp/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.
2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = /tmp/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.
3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = /tmp/logs
3manager.org.apache.juli.FileHandler.prefix = manager.
3manager.org.apache.juli.FileHandler.bufferSize = 16384
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
I would be really grateful if anyone had any thoughts.
I've just been through a similar process, not entirely successfully...
The first thing to note is that you need to be clear if you want to change the logging configuration for your web application, or for Tomcat itself. See logging documentation on the Tomcat website for some details - in particular:
This means that logging can be configured at the following layers:
- Globally. That is usually done in the ${catalina.base}/conf/logging.properties file. The file is specified by the java.util.logging.config.file System property which is set by the startup scripts. If it is not readable or is not configured, the default is to use the ${java.home}/lib/logging.properties file in the JRE.
- In the web application. The file will be WEB-INF/classes/logging.properties
Having done this I am able reconfigure my application's logging, when deployed to a standalone Tomcat server. However I was unable to get this to work with the Maven Tomcat plugin - I then discovered that somebody had filed bug MTOMCAT-127 which at the time of writing is unresolved, and would seem to describe what I've been seeing.
So not entirely successful - but I hope I can come back and update this answer once the MTOMCAT-127 issue has progressed...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With