appengine-java-vm-runtime
appengine-java-vm-runtime copied to clipboard
[WIP] Add support for logging based on google-cloud-logging
I'm trying to port over the new logging mechanism to the compat runtime to be used with a custom logging.properties file, but not having much luck.
In my test app, I have this in webapp\WEB-INF\logging.properties:
# Set the default logging level for all loggers to INFO
.level=INFO
# Override root level
com.foo.level=FINE
# Override parent's level
com.foo.bar.level=SEVERE
handlers=com.google.cloud.logging.LoggingHandler
com.google.cloud.logging.LoggingHandler.level=FINE
com.google.cloud.logging.LoggingHandler.log=gae_app.log
com.google.cloud.logging.LoggingHandler.resourceType=gae_app
com.google.cloud.logging.LoggingHandler.enhancers=com.google.cloud.logging.GaeFlexLoggingEnhancer
com.google.cloud.logging.LoggingHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=%3$s: %5$s%6$s
and appengine-web.xml has this:
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>YOUR-PROJECT-ID</application>
<version>YOUR-VERSION-ID</version>
<threadsafe>true</threadsafe>
<env>flex</env>
<beta-settings>
<setting name="machine_type" value="n1-standard-1"/>
<setting name="enable_app_engine_apis" value="true"/>
</beta-settings>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
</appengine-web-app>
@gregw This configuration doesn't seem to be working. I only see logs in the app stream and no sign of gae_app.log in the Stackdriver Logging UI. Any thoughts?
@meltsufin I'm not going to have a chance to run this myself for a few hours. But I'm guessing the problem is that this compat runs with the working directory at $JETTY_BASE rather than in the webapp itself. So your relative path to WEB-INF/logging.properties is not working. Try putting an absolute path there to confirm/deny
@lesv the SNAPSHOT is used because the LoggingHandler from google-cloud-java with the modifications to be enhanced for the monitored resource and traceid has not yet been released.
@gregw It looks like WEB-INF/logging.properties is being picked up fine based of the debugging logs that I added. I think the issue has to do with the initialization of the logging handler. It's probably failing, but we don't see any logs for it anywhere.
@meltsufin perhaps we need a PR on google-cloud-logging that will print any exceptions to stderr so we one can better debug logging problems in init?
@gregw Yes, that's a good idea. I also think we need to pull the zone stuff into this PR for now because it sounds like they won't be able to merge that PR and release in a while.