Skip to content

Commit

Permalink
Issue #67: Got Tomcat logging working correctly inside Eclipse.
Browse files Browse the repository at this point in the history
Had to do this in order to debug what was going on.
  • Loading branch information
karlmdavis committed Dec 28, 2014
1 parent 06ef7ae commit c08539e
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
27 changes: 27 additions & 0 deletions dev/README-DEVENV.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,30 @@ Each developer must edit their `~/.m2/settings.xml` file to contain the necessar
<activeProfile>justdavis-integration-tests</activeProfile>
</activeProfiles>
</settings>


### Tomcat (via Eclipse WTP)

References:

* [Eclipse WTP Tomcat FAQ](https://wiki.eclipse.org/WTP_Tomcat_FAQ)
* [Stack Overflow: Where can I view Tomcat log files in Eclipse?](http://stackoverflow.com/a/7354545/1851299)

During development, it's recommended that the web applications be run in Apache Tomcat via Eclipse's WTP plugin. This is recommended as it's both easy to use and also similar to the production deployment (which also uses Tomcat). The `devenv-install.py` script will create a standalone Tomcat installation for this purpose.

Within Eclipse, the Tomcat instance can be setup as follows:

1. TODO

Once setup and available, the following should be done to ensure that Tomcat is configured correctly for running the RPS applications:

1. Copy the sample logging properties file from `/rps-tourney-parent/dev/devenv-tomcat-logging.properties` to `/Servers/apache-tomcat-7.0.57 at localhost-config` directory in Eclipse's *Package Explorer*. Right-click the Tomcat server and select **Publish** to apply this configuration change.
2. Open the Tomcat server's run configuration in Eclipse, and configure it as follows:
1. Add the following VM arguments, each on a separate line:
* `-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager`
* `-Djava.util.logging.config.file=${resource_loc:/rps-tourney-parent/dev/tomcat-logging.properties}`
* `-Dlogback.configurationFile=${resource_loc:/rps-tourney-parent/dev/tomcat-logback.xml}`
* `-Dsun.io.serialization.extendedDebugInfo=true`
* `-Drps.service.config.path=${resource_loc:/rps-tourney-parent/rps-tourney-webapp/src/test/resources/rps-service-config-dev.xml}`
* `-Drps.webapp.config.path=${resource_loc:/rps-tourney-parent/rps-tourney-webapp/src/test/resources/rps-webapp-config-dev.xml}`
2. Set the working directory to: `${workspace_loc}/.metadata/.plugins/org.eclipse.wst.server.core/tmp0`
41 changes: 41 additions & 0 deletions dev/tomcat-logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<configuration scan="true" scanPeriod="5 seconds">
<!-- Required to ensure that JUL respects log level changes. -->
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator" />

<!-- This appender will be sent all of the app's logging statements. -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<!-- There's a bug in this class' logging, that causes spurious exceptions
if it's enabled at the debug level. -->
<logger
name="org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl"
level="info" />

<!-- These loggers will print all CXF requests/responses to the log, at
the 'info' level (set to 'warn' or higher to disable them). Actually uses
the application's custom LoggerForInbound and LoggerForOutbound classes,
which attempt to exclude passwords from the log output. -->
<logger name="org.apache.cxf.interceptor.LoggingInInterceptor"
level="info" />
<logger name="org.apache.cxf.interceptor.LoggingOutInterceptor"
level="info" />

<!-- This logger will print all Spring MVC requests/responses to the log,
at the 'trace' level (set to 'debug' or higher to disable it). Does not attempt
to escape passwords or other sensitive data; MUST NOT be enabled in production. -->
<logger
name="com.justdavis.karl.rpstourney.webapp.RequestResponseLoggingInterceptor"
level="trace" />

<!-- Set to the 'all' level when debugging issues with Spring MVC. -->
<logger name="org.springframework.web" level="info" />

<!-- Log at the INFO level and above by default, to the 'STDOUT' appender. -->
<root level="info">
<appender-ref ref="STDOUT" />
</root>
</configuration>
31 changes: 31 additions & 0 deletions dev/tomcat-logging.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
############################################################
# This is the Java Logging configuration file for Tomcat.
# Only Tomcat itself will use this. The applications hosted
# in it will use Logback.
############################################################

handlers = java.util.logging.ConsoleHandler
.handlers = java.util.logging.ConsoleHandler

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS,%1$tL %4$s %2$s - %5$s%6$s%n


############################################################
# 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].[/manager].level = INFO

# 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

0 comments on commit c08539e

Please sign in to comment.