GAE app.yaml:如何设置包含句点的env变量?

时间:2016-03-05 08:13:43

标签: google-app-engine yaml app-engine-flexible

我正在使用app.yaml查看GAE托管虚拟机,如此处所述https://cloud.google.com/appengine/docs/managed-vms/java/configuring-your-app-with-app-yaml

当我这样做时

env_variables:
  java.util.logging.config.file: 'WEB-INF/logging.properties'

我得到例外

google.appengine.api.yaml_errors.EventError: Value 'java.util.logging.config.file' for key in EnvironmentVariables does not match expression '^(?:[a-zA-Z_][a-zA-Z0-9_]*)$'

有没有办法通过app.yaml指定自定义logging.properties

3 个答案:

答案 0 :(得分:1)

试试这个:

env_variables:
  JAVA_USER_OPTS: -Djava.util.logging.config.file=webapps/root/WEB-INF/logging.properties

env_variables中的app.yaml部分用于设置环境变量。 not allowed,因此异常是有道理的。

您正在尝试设置java.util.logging.config.file,这是一个系统属性,而不是环境变量。要设置它,您需要在启动Java时提供-Djava.util.logging.config.file=<value>参数。 GAE Flexible image提供JAVA_USER_OPTS环境变量来自定义Java命令行,因此您可以使用它来自定义JUL设置(现在也建议在图像readme中使用)。

此外,WEB-INF/logging.properties值对我不起作用,因为当前目录为$JETTY_BASE,而不是$JETTY_BASE/webapps/root

答案 1 :(得分:1)

另一个答案不再正确。属性名称现在名为JAVA_OPTS

这里有完整的'秘密'变量名称 https://github.com/GoogleCloudPlatform/jetty-runtime#providing-loggingproperties-via-the-web-application

现在这是正确的设置:

 android.view.InflateException: Binary XML file line #3: Error inflating class <unknown>
   at android.view.LayoutInflater.createView(LayoutInflater.java:626)
   at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
   at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:470)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
   at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
   at com.fiberCinema.categories$MovieAdapter.getView(categories.java:193)
   at android.widget.AbsListView.obtainView(AbsListView.java:2742)
   at android.widget.ListView.makeAndAddView(ListView.java:1811)
   at android.widget.ListView.fillDown(ListView.java:697)
   at android.widget.ListView.fillFromTop(ListView.java:763)
   at android.widget.ListView.layoutChildren(ListView.java:1627)
   at android.widget.AbsListView.onLayout(AbsListView.java:2567)
   at android.view.View.layout(View.java:15640)
   at android.view.ViewGroup.layout(ViewGroup.java:4884)
   at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
   at android.view.View.layout(View.java:15640)
   at android.view.ViewGroup.layout(ViewGroup.java:4884)
   at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1766)
   at android.view.View.layout(View.java:15640)
   at android.view.ViewGroup.layout(ViewGroup.java:4884)
   at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:131)
   at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
   at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1389)
   at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:868)
   at android.view.View.layout(View.java:15640)
   at android.view.ViewGroup.layout(ViewGroup.java:4884)
   at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
   at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
   at android.view.View.layout(View.java:15640)
   at android.view.ViewGroup.layout(ViewGroup.java:4884)
   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
   at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
   at android.view.View.layout(View.java:15640)
   at android.view.ViewGroup.layout(ViewGroup.java:4884)
   at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
   at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
   at android.view.View.layout(View.java:15640)
   at android.view.ViewGroup.layout(ViewGroup.java:4884)
   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
   at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
   at android.view.View.layout(View.java:15640)
   at android.view.ViewGroup.layout(ViewGroup.java:4884)
   at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
   at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
   at android.view.View.layout(View.java:15640)
   at android.view.ViewGroup.layout(ViewGroup.java:4884)
   at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2379)
   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2087)
   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1263)
   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6611)
   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:812)
   at android.view.Choreographer.doCallbacks(Choreographer.java:612)
   at android.view.Choreographer.doFrame(Choreographer.java:582)
   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:798)
   at android.os.Handler.handleCallback(Handler.java:733)
   at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper...

答案 2 :(得分:1)

对于通用弹性环境,请使用此格式。

env_variables:
  JETTY_ARGS: -Djava.util.logging.config.file=WEB-INF/logging.properties

请参阅here