我已将我的 logback.xml 放在 war 之外,并将该文件包含在主 logback.xml 中。
问题是绝对路径与包含文件一起工作,但相对路径不工作 下面是代码:
<configuration scan="true" scanPeriod="30 seconds">
<include file="..//..//..//..//logback-new.xml" />
</configuration>
包含的文件路径:C:\Users\MB0000038\Documents\vuliv-server-development - 2\theapp\logback files
war 中的资源文件夹:C:\Users\MB0000038\Documents\vuliv-server-development - 2\theapp\AnalyticsAPI\src\main\resources
感谢任何帮助
最佳答案
根据Logback docs文件包含...
can use relative paths but note that the current directory is defined by the application and is not necessarily related to the path of the configuration file.
因此,给定您的相对路径:..//..//..//..//logback-new.xml
Logback 将查找那个 logback-new。 xml
应用程序当前工作目录上方的四个目录。
我怀疑您定义的相对路径好像应该是相对于您的 WAR 中的资源文件夹,但这不是它应该定义的方式。相反,它应该相对于应用程序的当前工作目录进行定义。如果 Logback 找不到要包含的文件,它将发出一条状态消息告诉您。
关于java - 相对路径在 lobgack.xml 包含文件中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46925429/