在从log4j切换到log4j2之后,我开始在输出中看到这样的错误
ERROR StatusLogger Caught javax.xml.parsers.ParserConfigurationException setting feature http://xml.org/sax/features/external-general-entities to false on DocumentBuilderFactory oracle.xml.jaxp.JXDocumentBuilderFactory@49993335: javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.ParserConfigurationException
at oracle.xml.jaxp.JXDocumentBuilderFactory.setFeature(JXDocumentBuilderFactory.java:218)
at org.apache.logging.log4j.core.config.xml.XmlConfiguration.setFeature(XmlConfiguration.java:212)
at org.apache.logging.log4j.core.config.xml.XmlConfiguration.disableDtdProcessing(XmlConfiguration.java:205)
at org.apache.logging.log4j.core.config.xml.XmlConfiguration.newDocumentBuilder(XmlConfiguration.java:194)
at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:92)
at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:454)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:386)
at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:261)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:616)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:637)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:567)
这些似乎根本不会影响日志输出,但是对于每隔几分钟运行一次的进程来说,这个异常非常烦人。寻找解决办法。
1条答案
按热度按时间vltsax251#
在别人遇到这个问题时回答我自己的问题。
我找到的唯一解决办法(可能不是正确的解决办法,或者有更好的解决办法)是添加
-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
添加到我的启动脚本xercesImpl-2.12.0.jar
到我的类路径(版本可能不重要,那只是我使用的版本)。