The shutdown hook used by o.a.c.startup.Catalina is Catalina$CatalinaShutdownHook. Maybe it could be generalized, or a similar class should be added to be used with o.a.c.startup.Tomcat.
If someone is going to create a copy of the shutdown hook class, maybe I should explain one implementation detail:
Note that the logging subsystem installs its own shutdown hook as well. When JVM shuts down, it starts all hooks in parallel without any order, so there is a risk that some log messages will be lost as the logging system will be shut down too early.
This issue is already solved in Catalina$CatalinaShutdownHook, but the solution works only when Tomcat's JULI ClassLoaderLogManager is used. It does not work with plain java.util.logging.LogManager which I think is used when running a JAR file.
I see that Tomcat7Runner.installLogger() may install "org.slf4j.bridge.SLF4JBridgeHandler". I do not know how to deal with that one either.
The solution works like the following:
First, it should be noted that the following 3 hooks are installed:
To ensure that the logging subsystem is shutdown by CatalinaShutdownHook only, the following is used:
1. "a)" is dealt with in ClassLoaderLogManager.reset() where it ignores a call from LogManager$Cleaner
2. "b)" is dealt with in Catalina.start() where it calls ClassLoaderLogManager.setUseShutdownHook(false) after installing its own shutdown hook
3. Catalina$CatalinaShutdownHook.run() calls ClassLoaderLogManager.shutdown()