如何指定要在Java Webstart应用程序中使用的注销配置? [英] How do I specify a logback configuration for use in a Java webstart application?

查看:111
本文介绍了如何指定要在Java Webstart应用程序中使用的注销配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将日志记录添加到许多内部Java Webstart应用程序中,最好使用logback日志记录框架和logback.groovy配置文件.我希望在webstart应用程序.jnlp文件中指定此名称,但尚不清楚如何执行此操作.

I want to add logging to a number of internal Java webstart applications, preferably using the logback logging framework and logback.groovy configuration files. I expect to specify this in the webstart application .jnlp file, but it's not clear how to do this.

我尝试将logback.groovy文件添加到主jar的资源(即包含我的main方法的文件)中,但没有被回滚获取.

I have tried adding the logback.groovy file in the resources of my main jar (i.e. that which contains my main method), but that didn't get picked up by logback.

我还尝试了各种尝试,将logback.groovy文件添加到.jnlp文件的<resources>部分:

I have also tried various attempts to add the logback.groovy file to the <resources> section of the .jnlp file:

<jnlp ...>
  <resources>
    <j2se version="$j2seVersion" />
    $dependencies // from maven-webstart-plugin

    // some reference to my logback configuration - e.g. 
    <dir href="log/" />
  </resources>
</jnlp>

值得注意的是,logback希望配置文件在类路径中作为其所在的文件夹而不是文件本身被引用-请参阅

It's worth noting that logback expects the configuration files to be referenced on the classpath as the folder in which it resides, not to the file itself - see FAQs.

但是,我真的不确定这将如何应用于Java Webstart.

However, I'm really not sure how this would apply to Java Webstart.

这可能吗?如果是这样,我该怎么办?

Is this possible? If so, how do I do this?

推荐答案

所以...我最终使用的方法是(符合Askel的评论)将logback.groovy配置文件放入/src/main/resources

So... the approach that I ended up using for this was (in line with Askel's comments) to put the logback.groovy configuration file into /src/main/resources.

但是,我们以多种不同的方式使用Java库,并且我不想默认情况下在jar中包含logback配置文件.在某种程度上,这是因为我们有几个库,并且注销对多个配置文件不能很好地发挥作用.另外,根据发行版,我想使用不同的logback配置.

However, we use our Java libraries in a number of different ways, and I didn't want to include the logback configuration file in the jar by default. In part, this is because we have several libraries, and logback doesn't play nicely with multiple configuration files. Also depending on the release, I wanted to use different logback configurations.

对于我们的Webstart版本,我们使用webstart-maven-plugin来构建库,组装依赖项等.但是进行此构建之前,我们将logback.groovy配置文件复制到/src/main/resources-这包括该库的内部版本中的文件.然后, 构建/发行后,您可以从/src/main/resources中删除配置文件.

For our webstart releases, we use the webstart-maven-plugin to build the library, assemble the dependencies etc. But before doing this build, we copy the logback.groovy configuration file to /src/main/resources - this includes the file in the build for that library. Then, after the build/release, you can remove the configuration file from /src/main/resources.

但是,此插件也将运行mvn install,它将把库 with 的logback配置文件放入本地maven存储库中.因此, 在删除构建/发行版/临时配置之后,我们执行另一个mvn clean install,它将覆盖该库.

However, this plugin will also run mvn install, which will put the library with the logback configuration file in your local maven repository. Therefore, after the build/release/temp configuration removal, we do another mvn clean install, which will overwrite that library.

这篇关于如何指定要在Java Webstart应用程序中使用的注销配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆