Can't get tomcat-maven-plugin to create a log file?

I run mvn tomcat: run-war target and get a directory structure that has a log directory. But alas, there is no magazine. I would just replace it with log4j logging, but it has proven difficult for a number of reasons.

I tried to explicitly configure the log file configuration. My pom.xml definition currently looks like this:

<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> 

During startup, I see the property being read. My properties file is below; I dump things in / tmp to make 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 very grateful if anyone had thoughts.

+7
source share
1 answer

I just went through a similar process, not quite successfully ...

First of all, you need to be clear if you want to change the logging configuration for your web application or for Tomcat itself. For more information, see the registration documentation on the Tomcat website , in particular:

This means that the record can be configured at the following levels:

  • On a global scale. This is usually done in the file $ {catalina.base} /conf/logging.properties. The file is specified in the java.util.logging.config.file System property, which is specified by startup scripts. If it is not readable or not configured, the default file is $ {java.home} /lib/logging.properties in the JRE.
  • In a web application. The file will be WEB-INF / classes / logging.properties

By doing this, I can reconfigure application logging when deployed to a stand-alone Tomcat server. However, I was not able to get this to work with the Maven Tomcat plugin - I then discovered that someone had filed an MTOMCAT-127 error , which at the time of writing was not resolved and seems to describe what I saw.

So, not entirely successful, but I hope I can return and update this answer after the MTOMCAT-127 problem has progressed ...

+2
source

All Articles