I m using embedded tomcat in my java application. below is my source code. however tomcat is not generating any log.
embedded = new Embedded();
e
I had just to figure out, how I can control the logging of the embedded Tomcat the same way the standalone version is doing it.
You will need the tomcat-juli.jar
, because it has a custom LogManager
in it. This LogManager
has advantages, since it is capable of registering multiple FileHandlers
. So it enables you to separate Logs per WebApp.
It is not enough to just include the tomcat-juli.jar
, but you also need to activate its LogManager
. This would be done through a JVM-Parameter:
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
Now it is possible to register FileHandlers
like shown in the Tomcat documentation.
With an additional JVM-Parameter you can set the path to the logging.properties
-File:
-Djava.util.logging.config.file=/logs/logging.properties
It is also possible to load the .properties
-File programmatically, but then you need to set a java.util.logging.config.class
with a JVM-Parameter, like above. In it's constructor you then must call LogManager.readProperties(...)
. Look here for more information.
Best regards