我在Web应用程序中使用log4j2并在我的用户主目录中使用配置文件。我已按照documentation:
中的说明在web.xml中指定了位置<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>file://${user.home}/someDirectory/log4j2.xml</param-value>
</context-param>
不幸的是,在Windows系统上,我得到了一个
java.net.URISyntaxException: Illegal character in authority at index 7: file://C:\Users\steinman/someDirectory/log4j2.xml
at java.net.URI$Parser.fail(Unknown Source)
at java.net.URI$Parser.parseAuthority(Unknown Source)
at java.net.URI$Parser.parseHierarchical(Unknown Source)
at java.net.URI$Parser.parse(Unknown Source)
at java.net.URI.<init>(Unknown Source)
at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:46)
...
因为反斜杠。文档在这里没有帮助,因为在示例中还有反斜杠,这是错误的。
有没有解决方案?
我无法使用斜杠对路径进行硬编码,因为应用程序也可以在其他系统上运行。
我不想将log4j2.xml放在应用程序中,因为实际上我有几个应用程序在Tomcat中运行,我想只使用一个配置文件来配置它们。当然,在不同的系统上,我想使用不同的日志配置。
答案 0 :(得分:0)
您可能发现了一个错误。你能在log4j2问题跟踪器中为此提出一张票(包括所有细节)吗?