jetty-runtime
jetty-runtime copied to clipboard
How to specify JUL logging configuration properties file
Re-posting a direct query from user:
In App Engine Standard, we used to have this in appengine-web.xml but now in app.yaml
system_properties:
java.util.logging.config.file: WEB-INF/logging.properties
It doesn’t seem to work however, INFO messages are still logged, even though it is set to WARNING.
I think part of the problem is that in Flex, there is nothing that is reading and propagating system_properties to the JVM.
With a custom Dockerfile, a workaround is to add the following line, specifying the location of the logging.properties for JUL:
CMD ["java","-Djetty.base=/var/lib/jetty","-Djava.util.logging.config.file=/var/lib/jetty/webapps/root/WEB-INF/logging.properties","-jar","/usr/local/jetty/start.jar"]
See also the #81 PR for #68, which implements JUL for the container and also set's this property.
Because JUL is provided by the JVM, it is a not a logging mechanism that can be easily hidden/separated between the container and application. So eventually we will be providing a JUL setup that the application will see. To configure this, they will have to manipulate the properties file that will be provided by the image, rather than provide their own and point the java.util.logging.config.file elsewhere.
In compat, the JUL was programmatically configured to ensure the container configuration is applied, however this results in a very non standard lifecycle for JUL.
Thus I think it would be better to establish the precedent that the jetty-runtime (maybe even openjdk-runtime) will setup JUL for you and then applications will modify that setup rather than do their own.
I forgot to update this issue with a better solution that currently works, which is to pass additional JVM arguments through an environment variable that can be specified in app.yaml. Instead of the CMD in Dockerfile, you can use this in app.yaml:
env_variables:
JAVA_USER_OPTS: -Djava.util.logging.config.file=/var/lib/jetty/webapps/root/WEB-INF/logging.properties
This also reminds me that we should consider setting the working directory to the web root, so that users can just use relative paths:
env_variables:
JAVA_USER_OPTS: -Djava.util.logging.config.file=WEB-INF/logging.properties
@gregw Regarding what you said about manipulating a properties file that will be provided by the image, is this something that will require a custom Dockerfile?