Log4j2在可执行jar

时间:2017-07-25 15:47:52

标签: java log4j2 xinclude

我有两个Web应用程序和一个可执行jar(总共3个)都使用非常相似的log4j2设置。

所有3个应用程序如下所示

<configuration status="OFF" xmlns:xi="http://www.w3.org/2001/XInclude">
 <Properties>
   <Property name="logfile-name">LOGNAME.log</Property>
   <Property name="logfile-folder">/home/${env:PUID}/utm/logs</Property>   
   <Property name="console-pattern">%d [%-6p] %C{1}.%M(%L) - %msg %n</Property>
   <Property name="logfile-pattern">%d [%-6p] %C{1}.%M - %msg %n</Property>    
   <Property name="max-log-size">100 MB</Property>
   <Property name="max-log-keep">12</Property>
   <Property name="rolling-interval">1</Property>
 </Properties>   

  <xi:include href="/opt/app/jtm/conf/jtm-log4j-appenders.xml" />
  <xi:include href="/opt/app/jtm/conf/jtm-log4j-loggers.xml" />
</configuration>

将属性传递到所有项目的appenders.xml和loggers.xml。它适用于Webapps。

可执行jarfile报告此错误

[Warning] log4j2.xml:23:66: Include operation failed, reverting to fallback. Resource error reading file as XML (href='/opt/app/jtm/conf/jtm-log4j-appenders.xml'). Reason: no !/ in spec

[Fatal Error] log4j2.xml:23:66: An include with href '/opt/app/jtm/conf/jtm-log4j-appenders.xml'failed, and no fallback element was found.

ERROR StatusLogger Error parsing jar:file:/C:/Workspaces/JTM/jtm-irtransferfile/dist/irtransferfile.jar!/log4j2.xml
     org.xml.sax.SAXParseException; systemId: jar:file:/C:/Workspaces/JTM/jtm-irtransferfile/dist/irtransferfile.jar!/log4j2.xml; lineNumber: 23; columnNumber: 66; An include with href '/opt/app/jtm/conf/jtm-log4j-appenders.xml'failed, and no fallback element was found.

我已经在网上的几个地方看过,没有什么可以直接回答这个问题。我确实感觉这可能是由于文件系统中的可执行jar读取,但我有点挣扎。

0 个答案:

没有答案