Author: markt Date: Wed Sep 24 12:42:26 2014 New Revision: 1627296 URL: http://svn.apache.org/r1627296 Log: Alternative solution for BZ56401 that doesn't trigger logging on shutdown
Added: tomcat/trunk/java/org/apache/catalina/startup/VersionLoggerListener.java (with props) Modified: tomcat/trunk/conf/server.xml tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties tomcat/trunk/webapps/docs/changelog.xml tomcat/trunk/webapps/docs/config/listeners.xml Modified: tomcat/trunk/conf/server.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/conf/server.xml?rev=1627296&r1=1627295&r2=1627296&view=diff ============================================================================== --- tomcat/trunk/conf/server.xml (original) +++ tomcat/trunk/conf/server.xml Wed Sep 24 12:42:26 2014 @@ -20,6 +20,7 @@ Documentation at /docs/config/server.html --> <Server port="8005" shutdown="SHUTDOWN"> + <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> <!-- Security listener. Documentation at /docs/config/listeners.html <Listener className="org.apache.catalina.security.SecurityListener" /> --> Modified: tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties?rev=1627296&r1=1627295&r2=1627296&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties Wed Sep 24 12:42:26 2014 @@ -121,4 +121,12 @@ userConfig.error=Error deploying web app userConfig.start=UserConfig: Processing START userConfig.stop=UserConfig: Processing STOP userConfig.deploy.threaded.error=Error waiting for multi-thread deployment of user directories to complete +versionLoggerListener.serverInfo.server.version=Server version: {0} +versionLoggerListener.serverInfo.server.built =Server built: {0} +versionLoggerListener.serverInfo.server.number =Server number: {0} +versionLoggerListener.serverInfo.os.name =OS Name: {0} +versionLoggerListener.serverInfo.os.version =OS Version: {0} +versionLoggerListener.serverInfo.os.arch =Architecture: {0} +versionLoggerListener.serverInfo.vm.version =JVM Version: {0} +versionLoggerListener.serverInfo.vm.vendor =JVM Vendor: {0} webAnnotationSet.invalidInjection=Invalid method resource injection annotation. Added: tomcat/trunk/java/org/apache/catalina/startup/VersionLoggerListener.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/VersionLoggerListener.java?rev=1627296&view=auto ============================================================================== --- tomcat/trunk/java/org/apache/catalina/startup/VersionLoggerListener.java (added) +++ tomcat/trunk/java/org/apache/catalina/startup/VersionLoggerListener.java Wed Sep 24 12:42:26 2014 @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.startup; + +import org.apache.catalina.LifecycleEvent; +import org.apache.catalina.LifecycleListener; +import org.apache.catalina.util.ServerInfo; +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; +import org.apache.tomcat.util.res.StringManager; + +/** + * Logs version information on startup. + */ +public class VersionLoggerListener implements LifecycleListener { + + private static final Log log = LogFactory.getLog(VersionLoggerListener.class); + + /** + * The string manager for this package. + */ + protected static final StringManager sm = StringManager.getManager(Constants.Package); + + + public VersionLoggerListener() { + // The log message is generated here to ensure that it appears before + // any log messages from the APRLifecycleListener. This won't be logged + // on shutdown because only the Server element in server.xml is + // processed on shutdown. + log(); + } + + + @Override + public void lifecycleEvent(LifecycleEvent event) { + // NO-OP + } + + + private void log() { + log.info(sm.getString("versionLoggerListener.serverInfo.server.version", + ServerInfo.getServerInfo())); + log.info(sm.getString("versionLoggerListener.serverInfo.server.built", + ServerInfo.getServerBuilt())); + log.info(sm.getString("versionLoggerListener.serverInfo.server.number", + ServerInfo.getServerNumber())); + log.info(sm.getString("versionLoggerListener.serverInfo.os.name", + System.getProperty("os.name"))); + log.info(sm.getString("versionLoggerListener.serverInfo.os.version", + System.getProperty("os.version"))); + log.info(sm.getString("versionLoggerListener.serverInfo.os.arch", + System.getProperty("os.arch"))); + log.info(sm.getString("versionLoggerListener.serverInfo.vm.version", + System.getProperty("java.runtime.version"))); + log.info(sm.getString("versionLoggerListener.serverInfo.vm.vendor", + System.getProperty("java.vm.vendor"))); + } +} Propchange: tomcat/trunk/java/org/apache/catalina/startup/VersionLoggerListener.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1627296&r1=1627295&r2=1627296&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Wed Sep 24 12:42:26 2014 @@ -64,6 +64,10 @@ correctly handle these cookies. (markt) </fix> <add> + <bug>56401</bug>: Log version information when Tomcat starts. + (markt/kkolinko) + </add> + <add> <bug>56530</bug>: Add a web application class loader implementation that supports the parallel loading of web application classes. (markt) </add> Modified: tomcat/trunk/webapps/docs/config/listeners.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/listeners.xml?rev=1627296&r1=1627295&r2=1627296&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/config/listeners.xml (original) +++ tomcat/trunk/webapps/docs/config/listeners.xml Wed Sep 24 12:42:26 2014 @@ -387,6 +387,19 @@ </subsection> + <subsection name="Version Logging Lifecycle Listener - org.apache.catalina.startup.VersionLoggerListener"> + + <p>The <strong>Version Logging Lifecycle Listener</strong> logs Tomcat, Java + and operating system information when Tomcat starts.</p> + + <p>This listener must only be nested within <a href="server.html">Server</a> + elements and should be the first listener defined.</p> + + <p>No additional attributes are supported by the <strong>Version Logging + Lifecycle Listener</strong>.</p> + + </subsection> + </section> <section name="Additional Implementations"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org