如何为xsbt-web-plugin的jetty()设置系统属性?
我已经将项目迁移到0.13.5,并开始使用 xsbt-web-plugin .
I've migrated my project to 0.13.5 and started using the xsbt-web-plugin.
我想将logback配置为使用由系统属性logback.configurationFile
设置的类路径之外的配置文件(这样我就可以将logconfig保留在war文件之外).
I'd like to configure logback to be using a configuration file outside the classpath which is set by a system property logback.configurationFile
(so I can keep the logconfig outside the war file).
以前我只需要设置:
System.setProperty("logback.configurationFile", "/some/path/logback.xml")
在project/build.scala
内的
并重新登录将获取它.
inside the project/build.scala
and logback would pick it up.
但是,将sbt升级到0.13.5并迁移到sbt中设置的xsbt-web-plugin系统属性后,似乎在运行时不可用(jetty).
However, after upgrading sbt to 0.13.5 and migrating to the xsbt-web-plugin system properties set in sbt don't seem to be available at runtime(jetty).
我尝试过以不同方式设置系统属性,也可以通过在启动sbt时使用-D
标志来传递它.
I've tried setting system properties in different ways, also by passing it along using the -D
flag when starting sbt.
在sbt控制台上,我可以看到该属性:
On the sbt console I can see the property:
eval sys.props("logback.configurationFile")
[info] ans: String = /some/path/logback.xml
但是它在Web应用程序内部不可用.
But it's not available inside the webapp.
关于如何将系统属性设置为可在webapp中使用的任何想法?
Any ideas on how to set system properties to be available inside the webapp?
我已经尝试了jetty()
和tomcat()
.行为相同.
I've tried both jetty()
and tomcat()
. Same behaviour.
更新: 我结束了:
jetty(options = new ForkOptions(runJVMOptions = Seq("-Dlogback.configurationFile=/some/path/logback.xml")))
有效.
按照 javaOptions
(不使用in container
),如Dependencies
和Delegates
下的inspect actual
所示:
javaOptions
alone (without in container
) should work, too, as could be seen in inspect actual
under Dependencies
and Delegates
:
[play-new-app] $ inspect actual container:javaOptions
[info] Task: scala.collection.Seq[java.lang.String]
[info] Description:
[info] Options passed to a new JVM when forking.
[info] Provided by:
[info] {file:/Users/jacek/sandbox/play-new-app/}root/container:javaOptions
[info] Defined at:
[info] /Users/jacek/sandbox/play-new-app/build.sbt:26
[info] Dependencies:
[info] */*:javaOptions
[info] Delegates:
[info] container:javaOptions
[info] *:javaOptions
[info] {.}/container:javaOptions
[info] {.}/*:javaOptions
[info] */container:javaOptions
[info] */*:javaOptions
[info] Related:
[info] */*:javaOptions