2015-01-09 79 views
7

私はLog4j2をテストしていますが、Apacheからライブラリをダウンロードしてクラスパス。 xercesImpl、xalan、xml-apis、シリアライザ、xsltcも追加しましたが、例外はそのまま残ります。私はスタックトレースと設定ファイルを表示します:問題http://apache.org/xml/features/xinclude testing log4j 2

<?xml version="1.0" encoding="UTF-8"?> 
<Configuration status="DEBUG"> 
    <Properties> 
     <Property name="log-path">C:/Logs/</Property> 
    </Properties> 
    <Appenders> 
     <RollingFile name="RollingFile" fileName="${log-path}/myexample.log" 
      filePattern="${log-path}/myexample-%d{yyyy-MM-dd}-%i.log"> 
      <PatternLayout> 
       <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%n</pattern> 
      </PatternLayout> 
      <Policies> 
       <SizeBasedTriggeringPolicy size="1 KB" /> 
      </Policies> 
      <DefaultRolloverStrategy max="4" /> 
     </RollingFile> 
    </Appenders> 
    <Loggers> 
     <Logger name="root" level="debug" additivity="false"> 
      <appender-ref ref="RollingFile" level="debug" /> 
     </Logger> 
     <Root level="debug" additivity="false"> 
      <AppenderRef ref="RollingFile" /> 
     </Root> 
    </Loggers> 
</Configuration> 


ERROR StatusLogger Error parsing C:\W7des\cliente\Test\bin\log4j2.xml javax.xml.parsers.ParserConfigurationException: Feature 'http://apache.org/xml/features/xinclude' is not recognized. 
    at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source) 
    at org.apache.logging.log4j.core.config.xml.XmlConfiguration.newDocumentBuilder(XmlConfiguration.java:85) 
    at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:137) 
    at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:44) 
    at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:472) 
    at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:442) 
    at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:254) 
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:419) 
    at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:138) 
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:207) 
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41) 
    at org.apache.logging.log4j.LogManager.getContext(LogManager.java:160) 
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:492) 
    at pac.Main.<clinit>(Main.java:14) 
    at java.lang.J9VMInternals.initializeImpl(Native Method) 
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:200) 

ありがとうございます。

答えて

0

Oracle JVMには、XIncludeをサポートするXMLパーサが付属しています。 この文書http://www-03.ibm.com/systems/resources/sdkguide.zos.pdfによれば、IBM J9 VMはXIncludeをサポートするXMLパーサもバンドルしています(21ページXML4J 4.5を参照)。

別個のXMLパーサー(JVMにバンドルされているXMLパーサの代わりにXercesを使用していると言われています)を使用する必要があるかどうかはわかりません。 どのバージョンのXerces/Xalanを使用していますか?クラスパスからカスタムXMLパーサを削除するとどうなりますか?

ところで、Log4jはXIncludeを有効にできない場合、WARNレベルのStatusLoggerメッセージを出力します。 "The DocumentBuilderFactory ..."で始まるWARNレベルのStatusLoggerメッセージが表示されますか?あなたの質問にこれらのメッセージを含めてください。

現在のところ、XInclude機能を有効にしようとするのを防ぐためにLog4jにはスイッチがありません。上記の問題は設定上の問題だと思われますが、解決できない場合は、そのようなスイッチを新しいLog4j機能として追加するように要求できます。これの場所はLog4j Jira issue trackerです。

+0

まず最初に、追加のライブラリなしでテストしたところ、エラーは同じでした。その後、Xerces(2.11)とXalan(2.7.1)の最後のバージョンを使用しました。私はそれらを削除しても問題は解決しません。コンソールで表示されるユニークなメッセージは、次のとおりです。 'エラーStatusLogger C:\ W7des \ cliente \ Test \ bin \ log4j2.xmlの解析エラー。javax.xml.parsers.ParserConfigurationException:Feature 'http://apache.org/xml/features/xinclude 'は認識されません。 エラーStatusLoggerログ設定なし ' 例外はDocumentBuilderFactoryについてです... –

+0

私が警告について尋ねた理由は、何らかの理由で' DocumentBuilderFactory.setXIncludeAware(true) 'が失敗した場合、Log4jはWARNメッセージを出力します。また:http://logging.apache.org/log4j/2.x/log4j-core/xref/org/apache/logging/log4j/core/config/xml/XmlConfiguration.html#L93 –

+0

プロパティを 'trueに設定しました。 'しかし、私は新しいメッセージを受け取っていませんでした...ここで私は 'org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)'の問題だと思います。もっと何ができますか? –

8

私のケースでは、古くなったxercesImpl-2.6.2.jarをクラスパスから削除すると助けになりました。

+2

確認済みです。関連する依存関係をxercesImplバージョン** 2.11.0 **に置き換え、エラーはなくなりました。ありがとう! – informatik01

+0

これは私にとってもうまくいった。ありがとう。 –

+0

または '-Djavax.xml.parsers.DocumentBuilderFactory = com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl 'をjvm引数に追加する – schemacs

0

gradleキャッシュからxercesディレクトリを削除した後、私の仕事をしました。

cd ~/.gradle/caches/modules-2/files-2.1 
rm -rf xerces 
関連する問題