小编ash*_*hah的帖子

可执行 jar 无法找到 logback.xml 文件

我有独立的应用程序,它捆绑在可执行文件中jar。在可执行文件的 MANIFEST 文件中jar,有一个类路径条目,其中jar列出了所有依赖项(包括所有 logback 实现 jar )。该可执行 jar 还包含logback.xml文件。

通过这种结构,当我使用简单的命令运行应用程序时java -jar MyApplication.jar,应用程序可以通过正确的日志记录正常运行。但这里的主要问题是,要更改日志级别,需要打开 jar 文件,而我不能要求客户端这样做。所以我放在logback.xmljar 之外,但现在所有日志记录都发生在控制台上。

我提到Logback 无法找到 logback.xml,即使它存在(在类路径上),并且提到的解决方案是将 logback.xml 捆绑在一个单独的 jar 中。但这个解决方案很糟糕。这样客户端就无法轻易更改日志级别。如何使其与 jar 外部的 logback.xml 一起使用。

我尝试添加logback.xmlMANIFEST 类路径条目以及其他依赖 jar 的条目,但没有成功。我的应用程序结构如下

+RootFolder
--MyApplication.jar
--logback-classic-1.1.3.jar
--logback-core-1.1.3.jar
--slf4j-api-1.7.7.jar
--Other-Dependency.jar
--logback .xml

有人已经解决这个问题了吗?我不想通过配置器使用编程配置。目前的解决方法是使用 option-Dlogback.configurationFile=logback.xml但如何使其在没有 out 的情况下工作?

logging logback

5
推荐指数
1
解决办法
4648
查看次数

maven-war-plugin不使用maven3,'warSourceExcludes'属性出错

当我用maven2运行我的工作时一切正常,但是使用maven 3(3.0.3)我得到的错误.请注意,我没有在任何地方定义'warSourceExcludes'属性

message : Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.0:war (default-war) on project specific-admin: Unable to parse configuration of mojo org.apache.maven.plugins:maven-war-plugin:2.0:war: When configuring a basic element the configuration cannot contain any child elements. Configuration element 'warSourceExcludes'.
cause : Unable to parse configuration of mojo org.apache.maven.plugins:maven-war-plugin:2.0:war: When configuring a basic element the configuration cannot contain any child elements. Configuration element 'warSourceExcludes'.
Stack trace : 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.0:war (default-war) on project specific-admin: Unable to parse configuration of mojo org.apache.maven.plugins:maven-war-plugin:2.0:war: When …
Run Code Online (Sandbox Code Playgroud)

maven-3

1
推荐指数
1
解决办法
4246
查看次数

标签 统计

logback ×1

logging ×1

maven-3 ×1